Skip to content

Commit 3e88398

Browse files
committed
feat(wizard): port migration rewriter to the EQL v3 domain family
The wizard now scaffolds EQL v3 columns, so `drizzle-kit generate` emits `ALTER COLUMN ... SET DATA TYPE eql_v3_<name>` — which Postgres rejects (no cast from text/numeric to an EQL domain). The post-agent rewriter matched only the single `eql_v2_encrypted` type, so those v3 statements slipped through unrepaired and failed at migrate time. Port the rewriter to the whole `eql_v3_*` concrete-domain family alongside legacy `eql_v2_encrypted`, mirroring the sibling CLI fix (#693): every mangled form drizzle-kit emits (incl. the 0.31.0+ `"undefined".` prefix and schema-qualified pgSchema tables), near-miss flagging for `SET DATA TYPE ... USING ...` it cannot safely repair, statement-breakpoints, and a clearer data-destroying / empty-table-only warning that points populated tables at the staged `stash encrypt` flow. Database introspection (`isEqlEncrypted`) now recognises BOTH `eql_v2_encrypted` and the `eql_v3_*` family as already-encrypted, matching migrate's `classifyEqlDomain` v3 convention — so the agent won't scaffold over existing encrypted data of either generation (v2 ciphertext stays valid and detected). Add a rewrite-migrations test suite (adapted from the CLI's).
1 parent 2a1dca6 commit 3e88398

5 files changed

Lines changed: 661 additions & 53 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
'@cipherstash/wizard': minor
3+
---
4+
5+
Teach the wizard's post-agent Drizzle step to repair EQL **v3** migrations, not
6+
just legacy EQL v2.
7+
8+
The wizard now scaffolds EQL v3 columns, so `drizzle-kit generate` emits
9+
`ALTER TABLE … ALTER COLUMN … SET DATA TYPE eql_v3_<name>` — which Postgres
10+
rejects (there is no cast from `text`/`numeric` to an EQL domain). The migration
11+
rewriter previously matched only the single `eql_v2_encrypted` type, so those v3
12+
statements slipped through unrepaired and failed at migrate time.
13+
14+
The rewriter is ported to match the whole EQL v3 concrete-domain family
15+
(`eql_v3_text_search`, `eql_v3_integer_ord`, …) alongside legacy
16+
`eql_v2_encrypted`, across every mangled form drizzle-kit emits (including the
17+
`"undefined".` prefix from 0.31.0+ and schema-qualified `pgSchema()` tables). It
18+
now also flags near-miss `SET DATA TYPE … USING …` statements it cannot safely
19+
repair instead of leaving broken SQL, and each rewritten file carries a clearer
20+
warning that the ADD+DROP+RENAME is data-destroying and safe only on an empty
21+
table — a populated table must use the staged `stash encrypt` flow. This
22+
re-converges the rewriter with the sibling copy in the `stash` CLI.
23+
24+
Database introspection also recognises v3 encrypted columns: `isEqlEncrypted`
25+
now reports both `eql_v2_encrypted` and the `eql_v3_*` family as already
26+
encrypted, so the agent won't scaffold over existing encrypted data of either
27+
generation.

0 commit comments

Comments
 (0)