Skip to content

feat: rename enum values in place, name the types the models do not create, and check view models in drift - #350

Merged
borderss merged 6 commits into
mainfrom
feat/189-193-232
Nov 28, 2026
Merged

borderss merged 6 commits into
mainfrom
feat/189-193-232

Conversation

@borderss

Copy link
Copy Markdown
Contributor

What and why

Renaming an enum value showed up as a new value plus a removed one, with a warning to rebuild the type (#189). diff --rename status.banned=blocked now writes one ALTER TYPE ... RENAME VALUE, rows keep their data, and the dry run hints at it the way it does for a column rename.

-- before: ALTER TYPE "status" ADD VALUE 'blocked'; plus a warning that 'banned' can't be removed
-- after:  ALTER TYPE "status" RENAME VALUE 'banned' TO 'blocked';

drift passed on a database adopted from a dump, while a migration made from the models alone failed on an empty database at the first column of a domain, composite or extension type (#193). After its verdict, drift now lists the types the models use and do not create, with the columns that use each. It is a note, so the exit code is unchanged.

drift never looked at view models, so a field renamed on a b.View model passed drift and failed at the first query (#232). drift now reports a view the models read that the database lacks, and each column a model reads that its view lacks, and fails on them. Views stay out of the snapshot. db-show lists materialized views after the tables. The third gap in #232, a key on an existing unique constraint, needs a builder API decision, so this PR leaves #232 open.

$ migrate drift
The views the models read differ from the database:
  view list_stats has no column subscriber_count

Decisions 172, 173 and 174 record the choices. docs/api.txt changed on purpose: RenameEnumValue, Hint.Enum and Hint.Value, ExternalTypes, RelationColumns, View, Schema.Views and Summary.MaterializedViews.

Closes #189
Closes #193
Part of #232

Checklist

  • The title follows Conventional Commits (feat:, fix:, docs: ...), since it becomes the squashed commit
  • The branch is rebased on main (git pull --rebase origin main), with no merge commits
  • Tests cover the change, and at least one fails without it
  • make fmt, make lint and make test pass
  • make test-pg passes, if the change reaches the database (and the other dialects' targets, if it touches them)
  • docs/api.txt is updated with go test ./tests/api -update, if the exported API changed on purpose
  • Docs are updated here or in ant-docs, if behaviour changed

Docs after release: docs/migrations/commands.mdx (--rename on an enum value, drift on views and the types note, db-show with materialized views), docs/migrations/generated-sql.mdx and docs/migrations/troubleshooting.mdx (enum value renames), docs/migrations/adopting.mdx (the types note; "From the models" leaves out domains and the like), docs/models/shared-tables-and-views.mdx (drift checks a view's columns).

@borderss
borderss force-pushed the feat/189-193-232 branch 2 times, most recently from c7a99d1 to c551602 Compare November 28, 2026 00:07
@borderss
borderss merged commit 3641ae9 into main Nov 28, 2026
15 checks passed
@borderss
borderss deleted the feat/189-193-232 branch November 28, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant