import { PrismaClient } from '@prisma/client'; import { hash } from 'bcryptjs'; const prisma = new PrismaClient(); async function main() { console.log('🌱 Starting database seed...'); // Seed initial guests const guests = [ { name: "Lerato Moyo", inviteCode: "LERATO2026", email: "lerato@example.com", partySize: 1, maxPax: 2, }, { name: "Denver Moyo", inviteCode: "DENVER2026", email: "denver@example.com", partySize: 1, maxPax: 2, }, { name: "Mr Denver Moyo", inviteCode: "QWERTY", partySize: 1, maxPax: 2, }, { name: "Miss Lerato Molema", inviteCode: "ASDF2026", partySize: 1, maxPax: 2, }, { name: "Mr & Mrs S Dewa", inviteCode: "ZXCV2026", partySize: 2, maxPax: 2, }, ]; console.log('📝 Seeding guests...'); for (const guest of guests) { await prisma.guest.upsert({ where: { inviteCode: guest.inviteCode }, update: {}, create: guest, }); } console.log(`✅ Seeded ${guests.length} guests`); // Seed admin user (password: admin123 - CHANGE IN PRODUCTION!) const adminPassword = process.env.ADMIN_PASSWORD || 'admin123'; const hashedPassword = await hash(adminPassword, 10); await prisma.admin.upsert({ where: { username: 'admin' }, update: {}, create: { username: 'admin', password: hashedPassword, email: 'admin@wedding.com', }, }); console.log('✅ Seeded admin user'); // Seed sample tables const tables = [ { name: 'Table 1', capacity: 8 }, { name: 'Table 2', capacity: 8 }, { name: 'Table 3', capacity: 10 }, { name: 'Table 4', capacity: 10 }, { name: 'Table 5', capacity: 6 }, ]; console.log('📝 Seeding tables...'); for (const table of tables) { await prisma.table.upsert({ where: { name: table.name }, update: {}, create: table, }); } console.log(`✅ Seeded ${tables.length} tables`); console.log('🎉 Database seed complete!'); } main() .catch((e) => { console.error('❌ Seed failed:', e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });