Files
KC-APP-Server/prisma/seed-dev.js
linusandClaude Sonnet 5 a29024407f feat(backend): guest-facing Wahl overview endpoint + dev seed
GET /api/wahl/guest/overview (guest JWT) returns the open Wahlen for the
guest's KC, each with its workshops and the guest's own current priorities
(null if not yet submitted) — everything the client needs to render the
Wahl form without any LT-only endpoint. Verified end to end against a local
Postgres (guest login -> overview -> submit -> re-fetch).

prisma/seed-dev.js: minimal dev fixture (one KC "DEV123" + Gemeinde + open
Wahl with three workshops).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-10 08:45:11 +02:00

36 lines
1.3 KiB
JavaScript

/* Minimal dev seed: one KC + Gemeinde + open Wahl with workshops.
Run: node prisma/seed-dev.js (backend/.env must point at the dev DB) */
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function main() {
const kc = await prisma.kc.upsert({
where: { inviteCode: 'DEV123' },
update: {},
create: { name: 'KC Dev 2026', inviteCode: 'DEV123' },
});
const gem = await prisma.gemeinde.upsert({
where: { kcId_name: { kcId: kc.id, name: 'Mustergemeinde' } },
update: {},
create: { kcId: kc.id, name: 'Mustergemeinde' },
});
let wahl = await prisma.wahl.findFirst({ where: { kcId: kc.id } });
if (!wahl) {
wahl = await prisma.wahl.create({
data: { kcId: kc.id, name: 'Samstag Teil 1', datumsSchluessel: '2026-06-13', teil: '1' },
});
await prisma.workshop.createMany({
data: [
{ wahlId: wahl.id, name: 'Töpfern', kapazitaet: 12, minTeilnehmer: 4 },
{ wahlId: wahl.id, name: 'Fußball', kapazitaet: 20, minTeilnehmer: 6 },
{ wahlId: wahl.id, name: 'Bandworkshop', kapazitaet: 8, minTeilnehmer: 3 },
],
});
}
console.log('KC', kc.id, 'invite', kc.inviteCode);
console.log('Gemeinde', gem.id);
console.log('Wahl', wahl.id);
}
main().finally(() => prisma.$disconnect());