Skip to content

Commit f9bd8e2

Browse files
committed
no-mistakes(document): Document serial-default adoption refusal in migration docs
1 parent 18e1e6e commit f9bd8e2

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎docs/features/migrations-and-drift.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,21 @@ preserves the PK through `RENAME COLUMN`) is not mistaken for a move. The read-o
123123
primary-key drift rather than throwing. Auto-migrating the move (adding the
124124
`add-primary-key` / `drop-primary-key` change kinds) is a documented future follow-up.
125125

126+
#### A legacy `serial` primary key (adoption-time refusal)
127+
128+
When migrating against a live Postgres database whose primary key is a legacy
129+
`serial` / `bigserial` column — one carrying a live `nextval(...)` default — and the
130+
metadata declares that `identity.primary` **without** `@generation`, the diff would
131+
otherwise emit `ALTER COLUMN … DROP DEFAULT`. That is destructive: every insert that
132+
omits the id starts failing. The missing `@generation` is genuinely ambiguous — it reads
133+
identically whether the author simply never declared it (and wants to keep
134+
auto-increment) or deliberately dropped it (to move the column onto app-assigned ids) —
135+
so `meta migrate` **refuses rather than guessing**, the same detect-and-refuse arc as the
136+
primary-key move above. Declare `@generation: increment` on the identity to keep the
137+
sequence, or pass `--allow drop-identity-default` if removing auto-increment is
138+
intentional. An identity that *does* declare `@generation: increment` never reaches this
139+
gate (its default diff is skipped), so only the undeclared case fires.
140+
126141
### Java
127142

128143
Schema migrations for Java projects are owned by the **TypeScript toolchain**

0 commit comments

Comments
 (0)