/** * Seed script – creates a default Organization and one demo Event. * Run: npm run db:seed -w packages/server */ import { PrismaClient } from "@prisma/client"; const prisma = new PrismaClient(); async function main() { const org = await prisma.organization.upsert({ where: { slug: "demo-org" }, update: {}, create: { name: "Demo Nonprofit", slug: "demo-org", primaryColor: "#2563eb", publicUrl: "https://bid.example.org", localHostname: "auction.event.lan", }, }); console.log(`Organization: ${org.name} (${org.id})`); const event = await prisma.auctionEvent.upsert({ where: { organizationId_slug: { organizationId: org.id, slug: "gala-2026" } }, update: {}, create: { organizationId: org.id, name: "Annual Gala 2026", slug: "gala-2026", description: "Our flagship annual fundraising gala.", startAt: new Date("2026-10-15T18:00:00Z"), endAt: new Date("2026-10-15T23:00:00Z"), status: "draft", timezone: "America/New_York", }, }); console.log(`Event: ${event.name} (${event.id})`); const liveAuction = await prisma.auction.upsert({ where: { id: "seed-live-auction" }, update: {}, create: { id: "seed-live-auction", eventId: event.id, type: "live", name: "Live Auction", sortOrder: 0, }, }); const silentAuction = await prisma.auction.upsert({ where: { id: "seed-silent-auction" }, update: {}, create: { id: "seed-silent-auction", eventId: event.id, type: "silent", name: "Silent Auction", sortOrder: 1, }, }); console.log(`Auctions: ${liveAuction.name}, ${silentAuction.name}`); const admin = await prisma.staffUser.upsert({ where: { email: "admin@example.org" }, update: {}, create: { organizationId: org.id, email: "admin@example.org", name: "Demo Admin", role: "admin", }, }); console.log(`Staff: ${admin.email}`); console.log("Seed complete."); } main() .catch((e) => { console.error(e); process.exit(1); }) .finally(() => prisma.$disconnect());