Skip to content

Conversation

@adaam2
Copy link
Member

@adaam2 adaam2 commented Jan 30, 2026

Summary

Root cause

mise clickhouse:diff uses Atlas to generate both Atlas and golang-migrate migration files. Atlas natively supports multi-statement SQL, so the generated Atlas migrations work fine. However, the golang-migrate output uses the exact same SQL content, and golang-migrate's ClickHouse driver only supports one statement per migration file.

This was never caught because:

  1. The PR authors likely use Atlas locally (which handles multi-statement fine)
  2. Production uses Atlas, not golang-migrate
  3. There is no CI check for the golang-migrate migration path

golang-migrate exists specifically as an alternative for developers who don't have an Atlas Pro account (see server/clickhouse/local/golang_migrate/README.md). Anyone using it would hit this error on mise clickhouse:migrate:

error: migration failed in line 0: ALTER TABLE `telemetry_logs` DROP INDEX ...;
ALTER TABLE `telemetry_logs` DROP INDEX ...;
 (details: code: 62, message: Syntax error (Multi-statements are not allowed))

Recovery

If you previously attempted these migrations with golang-migrate and hit a dirty state, run:

migrate -path server/clickhouse/local/golang_migrate -database "$GRAM_CLICKHOUSE_GOMIGRATE_URL" force 20251217163326

Then run mise clickhouse:migrate as normal.

Test plan

  • Run mise clickhouse:migrate with CLICKHOUSE_MIGRATION_ENGINE=golang-migrate and verify all migrations apply cleanly
  • Verify mise clickhouse:down rolls back correctly

🤖 Generated with Claude Code


Open with Devin

ClickHouse's golang-migrate driver does not support multi-statement
queries. The migrations introduced in #1415 and #1416 contained multiple
ALTER TABLE statements per file, which works fine with Atlas but fails
with golang-migrate.

Split the 3 multi-statement migrations into 9 single-statement files.
Also re-timestamps out-of-order postgres migrations.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@adaam2 adaam2 requested a review from a team as a code owner January 30, 2026 13:59
@changeset-bot
Copy link

changeset-bot bot commented Jan 30, 2026

⚠️ No Changeset found

Latest commit: 8357fe4

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

@vercel
Copy link

vercel bot commented Jan 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gram Ready Ready Preview, Comment Jan 30, 2026 2:01pm
gram-docs-redirect Ready Ready Preview, Comment Jan 30, 2026 2:01pm

Request Review

@github-actions
Copy link
Contributor

atlas migrate lint on server/migrations

Status Step Result
2 new migration files detected 20260130135207_install_redirect.sql
20260130135208_api-key-last-accessed.sql
ERD and visual diff generated View Visualization
Detected 2 non-linear changes
A rebase might fix this warning. Pull the latest git changes, and run 'atlas migrate rebase 20260130135207_install_redirect.sql 20260130135208_api-key-last-accessed.sql'
Files 20260130135207_install_redirect.sql and 20260130135208_api-key-last-accessed.sql were not added to the end of the migration directory. If 20260129164323_install_redirect.sql has already been applied to a database, 20260130135207_install_redirect.sql and 20260130135208_api-key-last-accessed.sql will be skipped as 20260129164323_install_redirect.sql has a higher version
Read the full linting report on Atlas Cloud

Copy link

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

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 potential bugs to report.

View in Devin Review to see 4 additional flags.

Open in Devin Review

@github-actions
Copy link
Contributor

atlas migrate lint on server/clickhouse/migrations

Status Step Result
No migration files detected  
ERD and visual diff generated View Visualization
No issues found View Report
Read the full linting report on Atlas Cloud

@github-actions github-actions bot added the preview Spawn a preview environment label Jan 30, 2026
@speakeasybot
Copy link
Collaborator

speakeasybot commented Jan 30, 2026

Preview Environment (PR #1420)

Preview environment scaled down after 12h of inactivity.
Re-add the preview label to restart.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why did these get renamed? I don't believe this should go in because it's completely unrelated with the clickhouse issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

this was a result of running clickhouse rebase i believe but might be wrong - the original issue i ran into was out of order migrations

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem is that these migrations are not clickhouse migrations - they're PG migrations, which was what stood out to me 🤔

@speakeasybot speakeasybot removed the preview Spawn a preview environment label Jan 31, 2026
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.

4 participants