Files
dance_school/scripts/seed.ts
2026-01-08 00:51:13 +03:00

30 lines
723 B
TypeScript

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);
});