th pearls: heal scheduled_at/tool_calls columns on pre-existing stores#178
Merged
Conversation
… stores The embedded Dolt engine has no `ALTER TABLE ... ADD COLUMN IF NOT EXISTS` (Error 1105, syntax error near `IF`). Two migrations shipped with exactly that form — pearls.scheduled_at (th-01aa6a) and session_messages.tool_calls (th-880f2c) — so the ALTER failed on every open and was swallowed by `let _ =`, meaning the columns were never added to any pre-existing store. Symptom: `th pearls due` errors `table "p" does not have column "scheduled_at"`. Move both into migrate_schema's COLUMN_HEALS loop, gated on column_exists() (the same proven pattern as pearl_comments.seq / jira_key): probe information_schema first, run a bare ADD COLUMN only when genuinely absent, commit best-effort. Regression test drops both columns and asserts a reopen re-adds them + due_scheduled() works + a second migrate is idempotent. Verified: healed the real repo's .smooth/dolt store (due went from the column error to "No pearls due"; SHOW COLUMNS confirms scheduled_at present). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: e5d6633 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Problem
th pearls due(shipped in #176) errors on any pre-existing pearl store:Root cause: the embedded Dolt engine has no
ALTER TABLE ... ADD COLUMN IF NOT EXISTS(Error 1105, syntax error nearIF). Two migrations shipped with exactly that form and were swallowed bylet _ = …, so the columns were never added to existing databases:pearls.scheduled_at(th pearls: schedulable pearls that speak up in the prime hook when due #176 / th-01aa6a) — my own new featuresession_messages.tool_calls(th-880f2c) — a pre-existing latent bug, same broken pattern, same fileFresh stores were fine (columns come from
CREATE TABLE), which is why tests and the throwaway-repo smoke passed — the ALTER path only runs on old stores.Fix
Move both into
migrate_schema's newCOLUMN_HEALSloop, gated oncolumn_exists()— the same proven pattern already used forpearl_comments.seqandjira_key: probeinformation_schemafirst, run a bareADD COLUMNonly when genuinely absent, commit best-effort. The two brokenADD COLUMN IF NOT EXISTSlines inensure_schemaare removed (with a pointer comment to where the heal now lives).Verification
test_migrate_heals_column_if_not_exists_columns: drops both columns, asserts a reopen re-adds them,due_scheduled()works, and a secondmigrate_schemais idempotent (no "duplicate column").cargo test -p smooai-smooth-pearls→ 148 passed.cargo fmt --check+cargo clippyclean.th pearls duethrew the column error; after, it returns "No pearls due" andSHOW COLUMNS FROM pearlsconfirmsscheduled_atis present.🤖 Generated with Claude Code