import { PrismaClient } from '@prisma/client'; import { Pool } from 'pg'; import { PrismaPg } from '@prisma/adapter-pg'; const connectionString = process.env['DATABASE_URL']; if (!connectionString) { throw new Error('DATABASE_URL is required for seeding'); } const pool = new Pool({ connectionString }); const adapter = new PrismaPg(pool); const prisma = new PrismaClient({ adapter }); /** * Seeds the local development database with minimal starter data. * Not intended for production use. */ async function main(): Promise { console.log('Seeding database...'); const hoa = await prisma.hoa.upsert({ where: { slug: 'sunrise-ridge' }, create: { name: 'Sunrise Ridge HOA', slug: 'sunrise-ridge', description: 'Development seed HOA', }, update: {}, }); console.log(`HOA: ${hoa.name} (${hoa.id})`); const unit = await prisma.unit.upsert({ where: { hoaId_identifier: { hoaId: hoa.id, identifier: '101' } }, create: { hoaId: hoa.id, identifier: '101', address: '1 Sunrise Ridge Dr, Unit 101', }, update: {}, }); console.log(`Unit: ${unit.identifier} (${unit.id})`); console.log('Seeding complete.'); } main() .catch((err) => { console.error(err); process.exit(1); }) .finally(() => prisma.$disconnect());