47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import { PrismaPg } from '@prisma/adapter-pg'
|
|
import { PrismaClient } from '../src/generated/prisma/client.js'
|
|
import { auth } from '@/lib/auth'
|
|
|
|
const adapter = new PrismaPg({
|
|
connectionString: process.env.DATABASE_URL!,
|
|
})
|
|
|
|
const prisma = new PrismaClient({ adapter })
|
|
|
|
async function main() {
|
|
console.log('🌱 Seeding database...')
|
|
|
|
// add admin user
|
|
await auth.api.createUser({
|
|
body: {
|
|
email: 'luu.dat.tham@gmail.com',
|
|
password: 'Th@m!S@m!040390',
|
|
name: 'Sam',
|
|
role: 'admin',
|
|
},
|
|
})
|
|
|
|
// // 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()
|
|
})
|