Repository navigation
Commit 3c5f3c5
fix(cli): a generated migration carries the field-level unique index driver-sql creates (#17208)
* fix(cli): a generated migration carries the field-level unique index the driver creates
Both migration formats emitted the table and none of the object's declared
uniqueness. Measured on live PostgreSQL 16.13, one object through all three
producers, pg_indexes per schema:
driver probe_pkey, uniq_probe_keyed_unique
sql gen probe_pkey
ts gen probe_pkey
Two rows with the same value in a `unique: true` field were refused by the
platform's table and accepted by both generated ones, with nothing reporting
it. The key set was already computed here for #16091's column widths; only
the index it implies was missing.
The sql format emits an inline `CONSTRAINT <name> UNIQUE (...)` — what knex's
`table.unique(columns, { indexName })` compiles to on PostgreSQL, so both
pg_indexes and pg_constraint agree with the driver — and the ts format emits
that knex call itself. Names come from a transcription of driver-sql's
`buildIndexName` (#5726 forbids a static driver import from a CLI production
module), pinned against the driver's own export.
Two shapes stay unemitted and are now NAMED in the generated file rather than
dropped: the ADR-0120 D3 organization-scoped composite, whose
COALESCE key part knex's schema builder cannot express, and object-level
`indexes[]`, which a second normalizer reads with different token semantics.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015QE8qk46e5CHJxyQEUjbf8
* chore(changeset): patch @objectstack/cli for the emitted unique index
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015QE8qk46e5CHJxyQEUjbf8
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4261fbc commit 3c5f3c5
4 files changed
Lines changed: 824 additions & 7 deletions
File tree
- .changeset
- packages/cli/src/commands
Lines changed: 64 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
0 commit comments