Add database seeding functionality, update Prisma configuration, and create seed script for initial data population
This commit is contained in:
25
prisma/seed.ts
Normal file
25
prisma/seed.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { env } from 'prisma/config';
|
||||
|
||||
const adapter = new PrismaBetterSqlite3({
|
||||
url: env('DATABASE_URL') || ''
|
||||
});
|
||||
const db = new PrismaClient({
|
||||
adapter
|
||||
});
|
||||
async function seed() {
|
||||
const year = new Date().getFullYear();
|
||||
await db.year.create({
|
||||
data: {
|
||||
year,
|
||||
budget: 3000
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
seed()
|
||||
.catch((e) => {})
|
||||
.finally(async () => {
|
||||
await db.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user