Skip to content

fix(clickhouse): renumber the external deployment id migration to 041 - #4734

Merged
0ski merged 1 commit into
mainfrom
oskar/fix-clickhouse-migration-collision
Aug 20, 2026
Merged

fix(clickhouse): renumber the external deployment id migration to 041#4734
0ski merged 1 commit into
mainfrom
oskar/fix-clickhouse-migration-collision

Conversation

@0ski

@0ski 0ski commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

goose up against internal-packages/clickhouse/schema panics on main today, so ClickHouse migrations cannot be applied from a fresh checkout. Renumbering the external deployment id migration from 040 to 041 clears it.

Root cause

Two migrations claim version 40. #4615 added 040_create_task_events_search_v2.sql, and #4661 added 040_add_task_runs_v2_external_deployment_id.sql a day later. #4661 was opened before #4615 merged, so 040 was genuinely free at branch time, and because the two files have different names there is no textual conflict for git or a rebase to surface. Both merged green, and no workflow in this repo runs goose, so the collision only shows up the first time someone actually migrates.

goose parses the numeric filename prefix as the version and refuses duplicates:

panic: goose: duplicate version 40 detected:
  .../040_create_task_events_search_v2.sql
  .../040_add_task_runs_v2_external_deployment_id.sql

It aborts while collecting the directory, before executing any SQL, so nothing was half applied and there is no migration state to repair.

This migration gets renumbered rather than the task_events_search_v2 one because goose keys on the version number and not the filename: version 40 is already recorded wherever 040 has been applied, so renaming that file would re-run an applied migration.

Verified with a full goose up against ClickHouse 26.2.19.43 (the image pinned in internal-packages/testcontainers): migrations apply cleanly through version 41, and task_runs_v2.external_deployment_id lands as String DEFAULT ''.

@changeset-bot

changeset-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 336fd5c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • internal-packages/clickhouse/schema/041_add_task_runs_v2_external_deployment_id.sql
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8487cad4-98c8-4b5b-a0aa-f07d81a5ade3

📥 Commits

Reviewing files that changed from the base of the PR and between 1990843 and 336fd5c.

📒 Files selected for processing (1)
  • internal-packages/clickhouse/schema/041_add_task_runs_v2_external_deployment_id.sql

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

040 was already claimed by 040_create_task_events_search_v2.sql (#4615) by the
time #4661 landed, so `goose up` panics with "duplicate version 40 detected"
while collecting the migration directory and applies nothing.

Renumber this one rather than the other: goose keys on the version number and
not the filename, so version 40 is already recorded wherever 040 has been
applied, and renaming that file would re-run an applied migration. This one has
never been applied anywhere, because collection aborts before any SQL runs.
@0ski
0ski marked this pull request as ready for review August 20, 2026 08:35

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@0ski
0ski force-pushed the oskar/fix-clickhouse-migration-collision branch from b31a02a to 336fd5c Compare August 20, 2026 08:36
@0ski
0ski enabled auto-merge (squash) August 20, 2026 08:37
@pkg-pr-new

pkg-pr-new Bot commented Aug 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@336fd5c

trigger.dev

npm i https://pkg.pr.new/trigger.dev@336fd5c

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@336fd5c

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@336fd5c

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@336fd5c

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@336fd5c

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@336fd5c

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@336fd5c

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@336fd5c

commit: 336fd5c

@0ski
0ski merged commit adaa8e9 into main Aug 20, 2026
52 checks passed
@0ski
0ski deleted the oskar/fix-clickhouse-migration-collision branch August 20, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants