Schema Diff does not detect foreign keys that reference a different schema

Offen
#10,786 0 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

@dpage arbeitet bereits daran.

Seit 18.11.2026.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
57/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
postgresql, python
Bereich
databases

Rechercherichtung

Start with web/pgadmin/browser/server_groups/servers/databases/schemas/tables/schema_diff_table_utils.py and trace the table equality check and table_constraint_comp. Compare how referenced schemas are handled when source and target schema names differ. Done means foreign keys to same named tables in different external schemas are reported as a difference and produce DDL, while references to the compared schemas remain normalized.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Schema Diff reports two tables as identical when their foreign keys reference tables of the same name in different schemas, so the difference is never shown and no DDL is generated for it.

For example, comparing schemas app and app_prod where app.orders has a foreign key to common_a.users and app_prod.orders has the same foreign key to common_b.users: the tables are reported as identical.

The cause is that the table comparison's keys_to_ignore (web/pgadmin/browser/server_groups/servers/databases/schemas/tables/schema_diff_table_utils.py) includes references, refnsp and remote_schema, so the referenced schema is dropped from the initial equality check and table_constraint_comp is never reached. Those keys are ignored so that a reference to the compared schema itself does not count as a difference when the source and target schemas have different names; the fix is to compare the referenced schema after normalising the source and target schema names, rather than ignoring it outright.

This was found by CodeRabbit whilst reviewing #10782, which fixes a related false difference; the gap predates that PR.

Vorherrschende Sprache
Python
Sterne
3.9k
Forks
922
Ø Merge
2 T. 3 Std.
Gemergte PRs (30 T.)
33

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus pgadmin-org/pgadmin4

Alle Issues in pgadmin-org/pgadmin4

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.