Initial commit of Dance School App
This commit is contained in:
29
scripts/seed.ts
Normal file
29
scripts/seed.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'dotenv/config';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import bcrypt from 'bcryptjs';
|
||||
|
||||
// Manually read .env if needed, but dotenv/config should handle it
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
const password = await bcrypt.hash('admin123', 10);
|
||||
const user = await prisma.user.upsert({
|
||||
where: { username: 'admin' },
|
||||
update: {},
|
||||
create: {
|
||||
username: 'admin',
|
||||
password,
|
||||
},
|
||||
});
|
||||
console.log('Admin user created:', user);
|
||||
}
|
||||
|
||||
main()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user