- migration writer now emits unique constraints (direct apply and live diff
previously dropped them); idempotent via the existing DO block
- unique constraint adopts a same-named model unique index with
ADD CONSTRAINT ... UNIQUE USING INDEX instead of building a second index
- dbml reader names unnamed unique indexes ukey_<table>_<cols> to match the
unique constraint naming
- foreign key deferral: Constraint.Deferrable/InitiallyDeferred are *bool
(nil = unspecified, never diffed); writers emit DEFERRABLE, DEFERRABLE
INITIALLY DEFERRED and NOT DEFERRABLE; live reader reads condeferrable and
condeferred; dbml reader/writer support deferrable and initially deferred
- tests and README/naming docs updated
Table.Columns/Constraints/Indexes/Relationships are Go maps, and every
writer, reader, diff, inspector, and merge code path that iterated them
directly was subject to Go's randomized map order, so identical input
could produce different output (or a different in-report violation/diff
order) on every run. Most visibly this showed up as bun/gorm `unique:`
struct tags changing order across consecutive `make models` runs with no
source change.
Fixed by sorting map iteration (by Sequence then Name, or alphabetically
for string-keyed maps) everywhere the order affects generated output or
first-match tie-break logic, across the bun, gorm, sqlite, dbml, drawdb,
pgsql, prisma, graphql, typeorm, drizzle, and dctx writers; the dctx,
prisma, and typeorm readers; the shared models.GetPrimaryKey/
GetForeignKeys helpers; pkg/diff, pkg/inspector, and pkg/merge; and the
TUI column/relationship pickers in pkg/ui.