Relspec dif bug #21

Closed
opened 2026-08-29 19:18:46 +00:00 by warkanum · 1 comment
Owner

Reproduction on relspec 062661f:

  1. Start an empty PostgreSQL 18 database.
  2. Run make migrate-apply.
  3. Immediately run make migrate-diff.

Expected: no drift.
Actual: 1,362 differences across DBML-managed tables.

The report marks columns, indexes, constraints, and foreign keys as modified despite relspec merge having just created them. It also treats PostgreSQL’s implicit NOT NULL constraints and generated PK indexes as extra. Extension
schemas and script-created tables explain some extras, but not modifications on every managed table.

Suggested report:

relspec merge output does not round-trip through relspec diff for DBML → PostgreSQL. On a fresh PostgreSQL 18 database, immediately after merge, diff reports 1,362 differences across managed tables, including implicit NOT
NULL constraints, generated primary-key indexes, columns, indexes, and FKs. This makes diff unusable as a drift gate. Reproduction: run Skaduwag’s make migrate-apply, then make migrate-diff using relspec build 062661f.

Reproduction on relspec 062661f: 1. Start an empty PostgreSQL 18 database. 2. Run make migrate-apply. 3. Immediately run make migrate-diff. Expected: no drift. Actual: 1,362 differences across DBML-managed tables. The report marks columns, indexes, constraints, and foreign keys as modified despite relspec merge having just created them. It also treats PostgreSQL’s implicit NOT NULL constraints and generated PK indexes as extra. Extension schemas and script-created tables explain some extras, but not modifications on every managed table. Suggested report: > relspec merge output does not round-trip through relspec diff for DBML → PostgreSQL. On a fresh PostgreSQL 18 database, immediately after merge, diff reports 1,362 differences across managed tables, including implicit NOT > NULL constraints, generated primary-key indexes, columns, indexes, and FKs. This makes diff unusable as a drift gate. Reproduction: run Skaduwag’s make migrate-apply, then make migrate-diff using relspec build 062661f.
Member

Implemented PR #23.

Branch: issue-21-diff-roundtrip
SHA: e8ac0e8c35

Summary: compare equivalent indexes by structural definition rather than generated name; normalize DBML/PostgreSQL column/default representations; align DBML and PostgreSQL foreign-key relationships; filter generated primary-key constraints/indexes and restrict PostgreSQL index/check queries to the correct catalog objects; add focused regression coverage and PostgreSQL reproduction fixtures.

Verification: GOTMPDIR=/home/hermes/.tmp GOCACHE=/home/hermes/.cache/go go test ./pkg/diff ./pkg/readers/dbml ./pkg/readers/pgsql (pass); GOTMPDIR=/home/hermes/.tmp GOCACHE=/home/hermes/.cache/go go test ./... (pass); GOTMPDIR=/home/hermes/.tmp GOCACHE=/home/hermes/.cache/go go build ./... (pass); git diff --check (pass). PostgreSQL live reproduction skipped: RELSPEC_TEST_PG_CONN unset and Docker/Podman unavailable.

Implemented PR #23. Branch: issue-21-diff-roundtrip SHA: e8ac0e8c35341dd0fe73ca9fdb295d30a46529d4 Summary: compare equivalent indexes by structural definition rather than generated name; normalize DBML/PostgreSQL column/default representations; align DBML and PostgreSQL foreign-key relationships; filter generated primary-key constraints/indexes and restrict PostgreSQL index/check queries to the correct catalog objects; add focused regression coverage and PostgreSQL reproduction fixtures. Verification: GOTMPDIR=/home/hermes/.tmp GOCACHE=/home/hermes/.cache/go go test ./pkg/diff ./pkg/readers/dbml ./pkg/readers/pgsql (pass); GOTMPDIR=/home/hermes/.tmp GOCACHE=/home/hermes/.cache/go go test ./... (pass); GOTMPDIR=/home/hermes/.tmp GOCACHE=/home/hermes/.cache/go go build ./... (pass); git diff --check (pass). PostgreSQL live reproduction skipped: RELSPEC_TEST_PG_CONN unset and Docker/Podman unavailable.
Sign in to join this conversation.
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wdevs/relspecgo#21