Skip to content

docs(clickhouse): require max+1 numbering and idempotent DDL#3633

Merged
ericallam merged 1 commit into
mainfrom
docs/clickhouse-migration-conventions
May 15, 2026
Merged

docs(clickhouse): require max+1 numbering and idempotent DDL#3633
ericallam merged 1 commit into
mainfrom
docs/clickhouse-migration-conventions

Conversation

@ericallam
Copy link
Copy Markdown
Member

Summary

Codify two rules for ClickHouse migration authors that came out of the 029/030 ordering incident on the TRI-9367 test cloud deploy:

  1. Number files to max(existing) + 1, never slot in below the latest. Goose runs in strict mode in the cloud deploy pipeline and refuses to apply a missing version below the current version — slotting a file in below an already-applied number blocks the next deploy.
  2. DDL must be idempotent (ADD COLUMN IF NOT EXISTS, DROP COLUMN IF EXISTS, CREATE TABLE IF NOT EXISTS, etc.) so a retry or out-of-order apply (goose up --allow-missing for local recovery, manual fixups) is a no-op rather than an error.

Where the rules live

  • internal-packages/clickhouse/CLAUDE.md — full rules + example for migration authors (and AI agents writing migrations).
  • .claude/REVIEW.md — added a 🔴 finding under "What makes a 🔴 Important finding" so PR reviewers flag either fault as blocking.

The existing migration files are left untouched; the idempotency requirement applies going forward.

Test plan

  • Next ClickHouse migration PR uses IF NOT EXISTS / IF EXISTS forms
  • No new migration files numbered below an already-applied version on test/prod

…ations

Codify two rules that came out of the 029/030 ordering incident (TRI-9367
test cloud deploy):

1. ClickHouse migration files must be numbered max(existing)+1. Goose runs
   in strict mode in the deploy pipeline and refuses to apply a missing
   version below the current version, which blocks the deploy. Branches
   that fell behind main need to renumber before merging.

2. DDL must be idempotent (ADD COLUMN IF NOT EXISTS, DROP COLUMN IF EXISTS,
   CREATE TABLE IF NOT EXISTS, etc.) so a retry or out-of-order apply
   (e.g. goose up --allow-missing for local recovery) is a no-op rather
   than an error.

Rules go in internal-packages/clickhouse/CLAUDE.md; reviewer-facing
summary added to .claude/REVIEW.md as a new 🔴 finding.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 15, 2026

⚠️ No Changeset found

Latest commit: f4cb375

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
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

Review Change Stack

Walkthrough

This PR documents operational governance rules for ClickHouse migrations managed by Goose. It adds detailed guidance to the ClickHouse package documentation specifying that migration files must be numbered sequentially (starting at current max + 1) and prohibiting downward version changes, since Goose in strict mode enforces this ordering. The documentation also requires migration DDL to be idempotent using patterns like IF NOT EXISTS and IF EXISTS to tolerate out-of-order application and retries. A corresponding 🔴-classified review checklist item is added to enforce these rules during code review.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: documentation updates establishing required conventions for ClickHouse migrations (numbering and idempotency).
Description check ✅ Passed The description covers the problem, rules, locations of changes, and test plan, though it diverges from the template structure by omitting the checklist and screenshots sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/clickhouse-migration-conventions

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 and usage tips.

@ericallam ericallam marked this pull request as ready for review May 15, 2026 17:12
Copy link
Copy Markdown
Contributor

@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 bugs or issues to report.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal-packages/clickhouse/CLAUDE.md`:
- Around line 13-16: The fenced code block that currently begins with ``` is
missing a language tag (MD040); update the opening fence to include a language
identifier (for example ```text or ```console) so the block becomes ```text and
retains the same contents (the goose run error lines), ensuring markdownlint no
longer flags MD040.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 94e61241-4e86-4b59-98f6-3637cd445710

📥 Commits

Reviewing files that changed from the base of the PR and between 5788573 and f4cb375.

📒 Files selected for processing (2)
  • .claude/REVIEW.md
  • internal-packages/clickhouse/CLAUDE.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: typecheck / typecheck
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js,jsx,json,md,css,scss}

📄 CodeRabbit inference engine (AGENTS.md)

Code formatting is enforced using Prettier. Run pnpm run format before committing

Files:

  • internal-packages/clickhouse/CLAUDE.md
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: triggerdotdev/trigger.dev

Timestamp: 2026-05-15T17:11:58.596Z
Learning: Before opening a PR with migrations, rebase and renumber migration files if main branch has added migrations during your work to avoid numbering conflicts below the new max.
Learnt from: CR
Repo: triggerdotdev/trigger.dev

Timestamp: 2026-05-15T17:11:58.596Z
Learning: Use `raw_` prefix for input tables where data lands first.
Learnt from: CR
Repo: triggerdotdev/trigger.dev

Timestamp: 2026-05-15T17:11:58.596Z
Learning: Use `_v1`, `_v2` suffixes for table versioning.
Learnt from: CR
Repo: triggerdotdev/trigger.dev

Timestamp: 2026-05-15T17:11:58.596Z
Learning: Use `_mv_v1` suffix for materialized views.
Learnt from: CR
Repo: triggerdotdev/trigger.dev

Timestamp: 2026-05-15T17:11:58.596Z
Learning: Use `_per_day` and `_per_month` suffixes for aggregation tables.
🪛 markdownlint-cli2 (0.22.1)
internal-packages/clickhouse/CLAUDE.md

[warning] 13-13: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

Comment thread internal-packages/clickhouse/CLAUDE.md
@ericallam ericallam enabled auto-merge (squash) May 15, 2026 17:15
Copy link
Copy Markdown
Collaborator

@nicktrn nicktrn left a comment

Choose a reason for hiding this comment

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

Goose runs in strict mode in the cloud deploy pipeline

We should also enforce this in dev to catch early

@ericallam ericallam merged commit 05d3ab1 into main May 15, 2026
40 checks passed
@ericallam ericallam deleted the docs/clickhouse-migration-conventions branch May 15, 2026 17:25
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