Skip to content

Commit 54e77c0

Browse files
committed
fix(driver-sql): pin the stale-TEXT remedy to the migration door, with no manual MODIFY in it
Claude-Session: https://claude.ai/code/session_016WV4cwiNRyb9B38wT2fjYj Co-authored-by: Claude <noreply@anthropic.com>
1 parent 16cc112 commit 54e77c0

2 files changed

Lines changed: 29 additions & 16 deletions

File tree

‎packages/drivers/driver-sql/src/sql-driver-12999-stale-text-remedy.test.ts‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,26 @@ describe('unkeyable TEXT column: the upgrade path names the real remedy (#12999)
145145
// The remedy, in full. Each clause is separately load-bearing: an operator
146146
// who converts the column without restating NOT NULL / DEFAULT on MySQL
147147
// ends up WORSE off than the no-op, having silently dropped the default.
148-
expect(message).toMatch(/backup taken first/);
149-
expect(message).toMatch(/restating the FULL column definition on MySQL/);
150-
expect(message).toMatch(/MODIFY drops a NOT NULL or DEFAULT you do not repeat/);
148+
// The remedy is the migration door, whose apply arm restates the whole
149+
// column definition from the catalog, so the message names that door and
150+
// what it keeps.
151+
expect(message).toMatch(/run "os migrate plan", then "os migrate apply"/);
152+
expect(message).toMatch(/keeping NOT NULL and DEFAULT/);
153+
expect(message).toMatch(/refuses with the rows named/);
151154
expect(message).toContain('varchar(64)');
152-
expect(message).toMatch(/next boot create this index/);
153-
154-
// ⛔ And it does NOT quietly become an instruction the driver will carry out
155-
// itself: the rewrite needs an exclusive metadata lock, so it stays manual.
156-
expect(message).toMatch(/does NOT rewrite the column for you/);
155+
expect(message).toMatch(/next boot then creates this index/);
156+
157+
// ⛔ And no manual path is left in it: the operator is not handed a
158+
// hand-written MODIFY, the statement that drops a NOT NULL or DEFAULT it
159+
// does not repeat. A manual path reintroduced here must bring back its
160+
// backup-first and restate-everything guidance, and this pin says so.
161+
expect(message).not.toMatch(/ALTER TABLE/i);
162+
expect(message).not.toMatch(/\bMODIFY\b/i);
163+
expect(message).not.toMatch(/by hand/i);
164+
165+
// ⛔ The plain boot sync still does not rewrite the column itself: the
166+
// rewrite needs an exclusive metadata lock, so it runs at the migration door.
167+
expect(message).toMatch(/plain boot sync does not convert the column itself/);
157168
expect(message).toMatch(/exclusive metadata lock/);
158169

159170
// ⛔ The CREATE-path advice must be GONE from this message — its presence is
@@ -236,7 +247,7 @@ describe('unkeyable TEXT column: the upgrade path names the real remedy (#12999)
236247

237248
// The stale half gets the conversion remedy…
238249
expect(message).toMatch(/"slug" \(declares `maxLength: 64`\)/);
239-
expect(message).toMatch(/restating the FULL column definition on MySQL/);
250+
expect(message).toMatch(/"os migrate apply": it converts the column\(s\) to varchar\(n\), keeping NOT NULL and DEFAULT/);
240251
// …and the genuinely unbounded half is still told to declare a bound, so a
241252
// composite key does not send the operator down one route for both columns.
242253
expect(message).toMatch(/Column\(s\) "note" in the same key declare no usable bound and DO need `maxLength`/);

‎packages/drivers/driver-sql/src/sql-driver-column-creation.ts‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@ export class ColumnCreationFacet {
168168
.map(([c, n]) => `"${c}" (declares \`maxLength: ${n}\`)`)
169169
.join(', ');
170170
const [firstColumn, firstBound] = [...staleBounds][0];
171-
// Named in full, deliberately. The mirror case in `schema-drift.ts` (the
172-
// unbounded field over a stale `varchar`) already had to derive this, and
173-
// the two MySQL `MODIFY` hazards it names are recorded twice more in this
174-
// file, on the datetime and time widenings: MODIFY does NOT repeat a
175-
// `NOT NULL`, and it DROPS a `DEFAULT` it does not restate. An operator
176-
// who follows an abbreviated version of this remedy ends up worse off than
177-
// the no-op they started with — a column that lost its default.
171+
// The remedy is the migration door, never a hand-written statement. The
172+
// two MySQL `MODIFY` hazards are recorded twice more in this file, on the
173+
// datetime and time widenings: MODIFY does NOT repeat a `NOT NULL`, and it
174+
// DROPS a `DEFAULT` it does not restate. An operator handed a bare MODIFY
175+
// ends up worse off than the no-op they started with — a column that lost
176+
// its default — so the message names `os migrate apply`, whose apply arm
177+
// (`mysql-text-to-varchar.ts`) restates the whole definition from the
178+
// catalog, and carries no manual path. A manual path added back here
179+
// brings its backup-first and restate-everything guidance with it.
178180
const others =
179181
offenders.length > staleBounds.size
180182
? ` Column(s) ${offenders

0 commit comments

Comments
 (0)