Repository navigation
fix(driver-sql): on MySQL, os migrate converts a keyed TEXT column to its declared varchar(n) - #39784
objectstack-fleet[bot] wants to merge 7 commits into
Conversation
…(n) at the migration door
…ule; pin the boot gate policy Claude-Session: https://claude.ai/code/session_016WV4cwiNRyb9B38wT2fjYj Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwiNRyb9B38wT2fjYj Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 15 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 164abd31717b0dc973dd9ff1620d607d91051241 && git checkout 164abd31717b0dc973dd9ff1620d607d91051241
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0635432d09c4d6d95eacd6c39aa0caee845f01e2 54e77c076fd7ae66b9ce18ea60d41aafee8a4c33 && git checkout -B drift-repro 0635432d09c4d6d95eacd6c39aa0caee845f01e2 && git merge --no-ff 54e77c076fd7ae66b9ce18ea60d41aafee8a4c33
node scripts/docs-audit/affected-docs.mjs --json 0635432d09c4d6d95eacd6c39aa0caee845f01e2
|
…h no manual MODIFY in it Claude-Session: https://claude.ai/code/session_016WV4cwiNRyb9B38wT2fjYj Co-authored-by: Claude <noreply@anthropic.com>
Requested by Elon · project thread
Part of #35862
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
Half A of the card, as ruling A1′ (card comment 7239720208) lays it out. The inbox object change is the next PR.
schema-drift.ts): a MySQL-only branch indiffManagedTable. When the emitter would build a field asvarchar(n)but the physical column is in the TEXT family, it reports the exportednarrow_varcharop with nofrom, at categoryneeds_confirm. The category is neverdestructive, because the artifact-pinned boot refuses ondestructivealone. NoDriftOpvariant is added.mysql-text-to-varchar.ts).sql-driver-schema-sync.tsis over 1,000 lines, so it only gains the two calls.detectManagedDriftcounts the rows whose value is longer than n. If there are none, the entry becomes awarning. Otherwise it gets anapplyLimitnaming the count and up to five row ids, andos migrate applyrefuses that entry.applyDriftOpInPlacesends a TEXT-sourcenarrow_varcharto the apply arm. It pins one connection and sets the boundedlock_wait_timeoutandSTRICT_ALL_TABLES. It then probes the rows again and refuses (skipped, rows named at warn) if any value is longer than n. Otherwise it runsMODIFYtovarchar(n), restating NOT NULL, DEFAULT (expression defaults included), character set, collation and comment from the catalog. The session's prior settings are restored.sql-driver-column-creation.ts,explainUnkeyableTextColumn): now points atos migrate plan/applyinstead of a hand-written ALTER.@objectstack/driver-sqlpatch.Tests
Run on head
16cc1125. Test file:sql-driver-35862-text-to-varchar.test.ts.narrow_varcharatneeds_confirm, with every member of the TEXT family;Temporal Conformance (live PG + MySQL), which runs the whole driver-sql suite withOS_EXPECT_LIVE_DIALECT_MATRIX=1):destructiveentry, so the gate answers ok, andapplyMigrationEntrieswithallowDestructive: falseconverts the clean column and skips the dirty one;Local readings
pnpm --filter @objectstack/driver-sql typecheckandvitest run src/sql-driver-35862-text-to-varchar.test.ts src/sql-driver-column-creation src/schema-drift: exit 0,Test Files 8 passed (8),Tests 87 passed | 5 skipped (92). The 2 skips in this file are the live pg and mysql cells: there is no server in this container.false &&beforeisTextFamilyColumn). Result:Tests 2 failed | 6 passed | 2 skipped. The two failures are the differ pins. The file was then restored from HEAD.dispatch-gates --ran: 74 derived families. 70 ran with an exit code and 4 are NOT MEASURED:check:dual-build-cjs-loadsandcheck:lean-entry-closure(prerequisite not met: the whole-repo dist was not built), andcheck:query-options-erasureandcheck:type-check-debt(stopped at a 240 s local cap on a shared box).node scripts/ci/snapshot-next.mjs --self-testexited 1 in its live stable-lane case. This diff does not touchscripts/ci/. CI reads all five.Temporal Conformance (live PG + MySQL)job is their reading.Acceptance notes
COUNT(*)with aCHAR_LENGTHfilter, plus the apply's re-probe. A clean column converts on its first pass, so the scan does not recur for it.scripts/pm/dev-worktree.shrefuses a resume when the branch name changes (claude/project-thread-01z3wqtoclaude/issue-35862-wip), so the worktree was built by hand from b612214.origin/main56bed06 then merged cleanly.Verification
Read first, by risk:
mysql-text-to-varchar.tsconvertMysqlTextColumnToVarchar: how the column definition is restated (the DEFAULT expression unescaping, and the NULL / NOT NULL choice).schema-drift.ts: the new MySQL branch indiffManagedTable, especially the category.sql-driver-schema-sync.ts: thenarrow_varcharrouting inapplyDriftOpInPlace.Two-minute check:
OS_TEST_MYSQL_URL=mysql://root:root@127.0.0.1:3306/conformance pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-35862-text-to-varchar.test.ts. Expected: 10 tests, and the MySQL cell's three live tests pass.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cwiNRyb9B38wT2fjYj