Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#105 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
csharp, postgresql
Área
databases

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
C#
Estrellas
67
Forks
4
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Nimblesite/DataProvider

Todos los issues de Nimblesite/DataProvider

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.