fix(store): MySQL workspaces migration fails on populated tables under strict mode#58
Draft
TYRMars wants to merge 1 commit into
Draft
fix(store): MySQL workspaces migration fails on populated tables under strict mode#58TYRMars wants to merge 1 commit into
TYRMars wants to merge 1 commit into
Conversation
…r strict mode The MySQL `projects` migration added `workspaces TEXT NOT NULL` with no DEFAULT, then backfilled in a separate UPDATE. Under strict SQL mode (MySQL 8 default STRICT_TRANS_TABLES) the ADD COLUMN itself aborts on a populated table because TEXT has no implicit default, so the migration fails before the backfill ever runs. Add the column nullable first, backfill, then MODIFY to NOT NULL — works across MySQL 5.7/8.x regardless of sql_mode while preserving the NOT NULL invariant. Mirrors the safe nullable-then-backfill pattern already used for the `automation` column. Also add the missing `ephemeral_tenants` helper: it was referenced from the Postgres and MySQL arms of `connect_all` but defined nowhere, so the crate failed to compile with either SQL feature. Adds the in-memory TenantStore fallback the call sites intended, mirroring the channel-store fallback in the same arms. Fixes #53 https://claude.ai/code/session_01TGN22RyFNGoC1KCPCrWKXn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #53
Problem
The MySQL
projectsmigration addedworkspacesasTEXT NOT NULLwith noDEFAULT, then backfilled in a separateUPDATE. Under strict SQL mode (MySQL 8 defaultSTRICT_TRANS_TABLES), theALTER TABLE … ADD COLUMN … TEXT NOT NULLitself aborts on a populated table because TEXT has no implicit default — so the migration fails before the backfill ever runs. This broke idempotent re-migration / upgrade on MySQL deployments that pre-date theworkspacescolumn.Fix
crates/harness-store/src/mysql.rs: add the column nullable first, backfill the legacy rows, thenMODIFYtoNOT NULL. This satisfies strict mode on populated tables, works across MySQL 5.7/8.x regardless ofsql_mode, and preserves theNOT NULLinvariant. It mirrors the safe nullable-then-backfill pattern already used for theautomationcolumn just below.Incidental fix
While verifying, I found the crate did not compile with either SQL feature:
ephemeral_tenants(...)was called from the Postgres and MySQL arms ofconnect_allbut defined nowhere. Added the missing in-memoryTenantStorefallback the call sites intended (there's no SQLTenantStoreimpl yet), mirroring the channel-store fallback in the same arms. Without this I couldn't compile-verify the MySQL migration path.Verification
cargo check -p harness-store --features mysql✅cargo check -p harness-store --features postgres✅cargo clippy -p harness-store --features mysql --all-targets -- -D warnings✅https://claude.ai/code/session_01TGN22RyFNGoC1KCPCrWKXn
Generated by Claude Code