Summary
On staging at 635adc7, a database created from the checked-in migration history is immediately reported as drifted by prisma migrate dev. The Phase 8 migrations create foreign keys that packages/database/prisma/schema.prisma does not declare.
Reproduction
- Create an empty PostgreSQL database.
- Set
DATABASE_URL to it.
- Run
pnpm db:generate && pnpm db:migrate.
- All ten checked-in migrations apply. Prisma then prompts for another migration because the resulting database differs from the current schema.
Unsafe generated diff
The generated reconciliation migration would drop 28 foreign keys and one index, including constraints on Pilot, PilotParticipant, PilotSupportCase, PilotFarmerImport, PilotDecision, PilotConfiguration, and TrainingAssignment. It was not retained because that would weaken referential integrity merely to silence drift.
The pre-existing local clycites database also contains 20260723160925_phase_9_enterprise_dashboard from origin/Daniel-Dev, which is not in staging history. That separate branch database was preserved; an isolated clycites_wp1_staging database reproduced the Phase 8 schema mismatch independently.
Provenance
git blame and migration history point to commit 3cb62a2 (feat(pilot): add bootstrap and preflight scripts for pilot management) as introducing both the Phase 8 schema and migrations in their inconsistent state.
Required resolution
Reconcile schema.prisma with the intended Phase 8 referential-integrity contract. Prefer restoring the missing Prisma relation declarations if the migration constraints are authoritative. Add a fresh-database CI check that applies all migrations and then verifies zero schema drift. Do not resolve this with db push, migrate reset against shared data, or a migration that drops the constraints without an explicit architecture decision.
Blocks
Blocks WP1 hardening baseline closeout because the brief requires migration-clean database initialization before integration tests.
Summary
On
stagingat635adc7, a database created from the checked-in migration history is immediately reported as drifted byprisma migrate dev. The Phase 8 migrations create foreign keys thatpackages/database/prisma/schema.prismadoes not declare.Reproduction
DATABASE_URLto it.pnpm db:generate && pnpm db:migrate.Unsafe generated diff
The generated reconciliation migration would drop 28 foreign keys and one index, including constraints on
Pilot,PilotParticipant,PilotSupportCase,PilotFarmerImport,PilotDecision,PilotConfiguration, andTrainingAssignment. It was not retained because that would weaken referential integrity merely to silence drift.The pre-existing local
clycitesdatabase also contains20260723160925_phase_9_enterprise_dashboardfromorigin/Daniel-Dev, which is not in staging history. That separate branch database was preserved; an isolatedclycites_wp1_stagingdatabase reproduced the Phase 8 schema mismatch independently.Provenance
git blameand migration history point to commit3cb62a2(feat(pilot): add bootstrap and preflight scripts for pilot management) as introducing both the Phase 8 schema and migrations in their inconsistent state.Required resolution
Reconcile
schema.prismawith the intended Phase 8 referential-integrity contract. Prefer restoring the missing Prisma relation declarations if the migration constraints are authoritative. Add a fresh-database CI check that applies all migrations and then verifies zero schema drift. Do not resolve this withdb push,migrate resetagainst shared data, or a migration that drops the constraints without an explicit architecture decision.Blocks
Blocks WP1 hardening baseline closeout because the brief requires migration-clean database initialization before integration tests.