Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

migrate --allow-destructive drops EVERY foreign key when the database already matches the schema

Aperta
#105 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp, postgresql
Ambito
databases

Direzione di ricerca

Start with the DataProviderMigrate migrate --allow-destructive entry point and reproduce the issue against PostgreSQL 16 using the unchanged schema. Compare the destructive path with the additive path and inspect the integrity-check output. Done means a converged schema retains all 25 foreign keys, removes only undeclared structures, passes the integrity check, and remains idempotent.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

DataProviderMigrate migrate --allow-destructive run against a database that
is already converged with the supplied schema drops every foreign key in
the database
, then fails its own integrity check listing the constraints it
just removed.

The schema is unchanged between runs. Nothing in it asks for a constraint to
be removed.

Reproduction

Postgres 16 in Docker, one unmodified schema file, nothing else touching the DB.

run 1 — additive     (fresh database)  -> 25 foreign keys, "Schema integrity check passed"
run 2 — additive     (same schema)     -> 25 foreign keys, passes   # additive is idempotent
run 3 — destructive  (same schema)     ->  0 foreign keys, "SCHEMA INTEGRITY CHECK FAILED"

Verified separately that a destructive run against a fresh database is
fine (creates 25 and passes); it is the destructive run against an
already-migrated database that destroys them. So the failure is on exactly the
path an operator uses in production, where the database is always already
converged.

Count query:

SELECT count(*) FROM pg_constraint WHERE contype = 'f';

Output tail from the destructive run

Migration completed successfully
SCHEMA INTEGRITY CHECK FAILED
public.tenant_credit: missing foreign key FK_tenant_credit_tenant_id on (tenant_id)
public.tenant_members: missing foreign key FK_tenant_members_tenant_id on (tenant_id)
public.conversations: missing foreign key FK_conversations_config_id on (config_id)
public.messages: missing foreign key FK_messages_conversation_id on (conversation_id)
...23 more

"Migration completed successfully" is printed immediately before the integrity
check reports the damage, so a caller checking only that line sees success.

Impact

Severe, and aimed squarely at production. The consuming project's documented
migration procedure is: additive migrate, deploy the code, then
migrate --allow-destructive to drop what the schema no longer declares. That
final step is exactly the reproduction above, so following the intended
process strips the production database of all referential integrity while
reporting "Migration completed successfully".

Exit code is 1 and the constraints are already gone by then — the drop is not
rolled back when the integrity check fails.

Expected

A destructive migrate removes only the structure the schema no longer
declares. A schema that still declares all 25 foreign keys must leave all 25
in place, and the run must be idempotent, exactly as the additive path already is.

Lingua principale
C#
Stelle
67
Fork
4
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Nimblesite/DataProvider

Tutte le issue di Nimblesite/DataProvider

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.