This commit is contained in:
2025-12-12 17:10:54 +07:00
commit 2c244b77fb
53 changed files with 13115 additions and 0 deletions

8
prisma/schema.prisma Normal file
View File

@@ -0,0 +1,8 @@
generator client {
provider = "prisma-client"
output = "../src/generated/prisma"
}
datasource db {
provider = "postgresql"
}

36
prisma/seed.ts Normal file
View File

@@ -0,0 +1,36 @@
import { PrismaClient } from '../src/generated/prisma/client.js'
import { PrismaPg } from '@prisma/adapter-pg'
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL!,
})
const prisma = new PrismaClient({ adapter })
async function main() {
console.log('🌱 Seeding database...')
// Clear existing todos
await prisma.todo.deleteMany()
// Create example todos
const todos = await prisma.todo.createMany({
data: [
{ title: 'Buy groceries' },
{ title: 'Read a book' },
{ title: 'Workout' },
],
})
console.log(`✅ Created ${todos.count} todos`)
}
main()
.catch((e) => {
console.error('❌ Error seeding database:', e)
process.exit(1)
})
.finally(async () => {
await prisma.$disconnect()
})