Database Seeding

47 seed files populate the database with reference data, test fixtures, and real German funding programs.

Entry Points

FilePurpose
backend/src/db/seeds/index.tsMain orchestrator — manages seed order and dependencies
backend/src/db/seeds/minimal.tsMinimal seed: 3 Users, 3 Buildings, 5 Projects (<30s, used for PR Preview Deployments)

Deterministic UUIDs

All seed records use deterministic UUIDs for idempotency:

import { seedUuid, SEED_NAMESPACES } from './seed-utils';
seedUuid(SEED_NAMESPACES.USER, 'admin@renewa.de');

Seed Pattern

  1. Check for marker record
  2. Skip if already seeded
  3. Insert with seedUuid()

This makes seeds idempotent and incremental. Auto-runs on startup when AUTO_SEED=true.

Large Seed Files

Seed FileSizeContent
document-templates-data.ts319KBDocument template definitions
products.ts173KBFull product catalog
typology-u-values.ts173KBBuilding U-value reference data
hubspotPropertyMappings.ts70KBHubSpot field mappings
document-obtaining.ts64KBDocument workflow data
form-builder/fields.ts45KBForm field definitions

Infrastructure Seeds

CategorySeeds
OrganizationDepartments, employees, roles
WorkflowsWorkflow definitions, steps, transitions
FormsForm templates, field definitions
DocumentsTemplates, collection settings
PermissionsRoles, permissions, assignments

Real German Funding Programs

Seeds include actual funding program data:

  • KfW BEG WG — Bundesfoerderung fuer effiziente Gebaeude (Wohngebaeude)
  • KfW BEG EM — Einzelmassnahmen
  • BAFA BEG EM — BAFA efficiency measures
  • IFB Hamburg — Regional Hamburg programs

Running Seeds

make db-seed          # Run all seeds
AUTO_SEED=true        # Auto-seed on container startup

See Makefile Commands for all database commands.

Key Files

  • backend/src/db/seeds/index.ts
  • backend/src/db/seeds/minimal.ts
  • backend/src/db/seeds/seed-utils.ts
  • backend/src/db/seeds/*.ts (47 files)

See Also