fix(clickhouse): renumber task_kind migration 029 → 031#3631
Conversation
|
WalkthroughThis pull request adds a ClickHouse schema migration to introduce a Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Devin Review found 1 potential issue.
🐛 1 issue in files not directly in the diff
🐛 Renaming already-merged goose migration causes duplicate column application on deployed environments (internal-packages/clickhouse/schema/031_add_task_kind_to_task_runs_v2.sql:2-3)
Migration 029_add_task_kind_to_task_runs_v2.sql was already merged to main (in commit be1a6cf8d) and may have been applied in existing environments. Renaming it to 031_ means goose will treat it as a brand-new migration: the old version 029 is recorded as applied in goose's goose_db_version table, but the file no longer exists; meanwhile, version 031 appears as a new unapplied migration. Running goose up will attempt to execute ALTER TABLE trigger_dev.task_runs_v2 ADD COLUMN task_kind ... again, which will fail in ClickHouse because the column already exists (the DDL does not use IF NOT EXISTS). No other ADD COLUMN migration in the schema directory uses IF NOT EXISTS either, so there's no established pattern of idempotent column additions to fall back on.
View 1 additional finding in Devin Review.
Migration 030_create_sessions_v1.sql landed on main on 2026-04-28 (PR #3417) and was applied to test/prod ClickHouse on subsequent deploys. Migration 029_add_task_kind_to_task_runs_v2.sql was authored later on 2026-05-10 as part of the Sessions primitive PR, after 030 was already at version 30 in the goose history. The next deploy fails because goose strict-mode refuses to apply a missing version 'before' current_version 30: goose run: error: found 1 missing migrations before current version 30: version 29: 029_add_task_kind_to_task_runs_v2.sql Renumber to 031 so goose applies it as the next version after 030. SQL is unchanged.
ed86704 to
775287c
Compare
Summary
Renumber
029_add_task_kind_to_task_runs_v2.sql→031_add_task_kind_to_task_runs_v2.sqlto fix a deploy-blocking out-of-order migration, and make the DDL idempotent withADD COLUMN IF NOT EXISTS/DROP COLUMN IF EXISTS.Root cause
030_create_sessions_v1.sqllanded on main on 2026-04-28 (PR feat: Sessions - bidirectional durable agent streams #3417) and was applied to test cloud ClickHouse on a subsequent deploy. Current goose version on test ClickHouse: 30.029_add_task_kind_to_task_runs_v2.sqlwas authored later on 2026-05-10 as part of the Sessions primitive PR series (be1a6cf8).Fix
031_*(next available number after 030). Goose now treats it as a new migration after 030 and applies it cleanly on test/prod where the column does not yet exist.ADD COLUMN IF NOT EXISTS). The original 029 may have been applied in environments that ran goose with--allow-missing(e.g. some local dev databases) — those would have the column already, and the rename causes goose to see 031 as new and re-attempt the ADD. Idempotent DDL keeps that path safe. TheDownmirrors withDROP COLUMN IF EXISTS.Test plan
task_kindcolumn shows up ontrigger_dev.task_runs_v2post-migrationgoose up