import { PrismaClient } from '@prisma/client' import { randomBytes, scryptSync } from 'node:crypto' const prisma = new PrismaClient() function hashPassword(password) { const salt = randomBytes(16).toString('base64url') const derivedKey = scryptSync(password, salt, 64).toString('base64url') return `scrypt$${salt}$${derivedKey}` } async function upsertUser({ email, password }) { const passwordHash = hashPassword(password) await prisma.user.upsert({ where: { email }, update: { passwordHash }, create: { email, passwordHash } }) } async function main() { await upsertUser({ email: 'student@example.com', password: '123456' }) } main() .then(async () => { await prisma.$disconnect() }) .catch(async (error) => { console.error('Seed failed:', error) await prisma.$disconnect() process.exit(1) })