refactor(infrastructure): delegate xatu migrations to xatu-cbt#139
Merged
Conversation
xatu split its ClickHouse migrations into database-agnostic per-schema sets (xatu/observoor/admin), each applied to a target database and tracked in its own schema_migrations_<set> table. Rather than re-implement that layout here, delegate the entire xatu-migration step to the xatu-cbt binary, which now owns it via a dedicated `infra migrate-xatu` subcommand. - Replace the in-tree runXatuMigrations (flat layout, single `default` db, global schema_migrations) with migrateXatu, which execs `xatu-cbt infra migrate-xatu --xatu-ref <ref>` against the local cluster. - Drop the now-dead helpers (parseXatuCBTEnv, createXatuDatabases, applyXatuMigrationSet) and the golang-migrate / clickhouse-go / godotenv dependencies (go mod tidy). Production safety is unchanged: the call stays behind the existing local-only guard (xatuSource == local), and xatu-cbt applies the same guard internally, so hybrid/external mode never migrates the remote/production xatu cluster. Requires the matching xatu-cbt change (the `infra migrate-xatu` subcommand). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
samcm
approved these changes
Jun 17, 2026
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.
Summary
xatu restructured its ClickHouse migrations into database-agnostic per-schema sets (
xatu→default,observoor→observoor,admin→admin), each applied to its target database and tracked in its ownschema_migrations_<set>table (hard cutover — the old flat layout and globalschema_migrationsare gone).xcli used to re-implement migration-running itself (pointing golang-migrate at the flat
deploy/migrations/clickhousedir, singledefaultdb). That breaks against the new layout. Rather than duplicate the new per-set logic here, this PR delegates the whole xatu-migration step to thexatu-cbtbinary, which now owns it.What changed
Start()now callsmigrateXatu(ctx)instead of the in-treerunXatuMigrations.migrateXatuexecsxatu-cbt infra migrate-xatu --xatu-ref <ref>(a new, CBT-free subcommand) against the local cluster.runXatuMigrations,createXatuDatabases,applyXatuMigrationSet,parseXatuCBTEnv, and thexatuMigrationSettype/var.go mod tidydropped the now-unused direct deps:golang-migrate/migrate,ClickHouse/clickhouse-go,joho/godotenv(and transitivech-go).Net: −210 / +25 lines across
manager.go+go.mod/go.sum.Why delegate instead of duplicate
The new per-set / per-database /
schema_migrations_<set>logic now lives in exactly one place (xatu-cbt), which is also the component that clones the xatu repo and stands up the local xatu cluster. xcli keeps its per-networkSetupNetworkloop unchanged. We use a dedicatedmigrate-xatusubcommand rather thanxatu-cbt infra start --run-migrations, because the latter also runs CBT setup for a single network — which would conflict with xcli's multi-network orchestration.Production safety
Unchanged and defense-in-depth:
xatuSource == constants.InfraModeLocalguard, so hybrid/external mode (remote/production xatu) never triggers it.xatu-cbt'smigrate-xatuapplies the same local-only guard internally.localhost; the external URL only configures the distributed-table pointer inside the local nodes.Config generation
No changes needed. The generated
cbt.yamlstill pointsexternal.defaultDatabaseatdefault(where thexatuset lands) andtransformations.defaultDatabaseat the per-network db — both unchanged by the restructure (only how migrations are applied changed, not where tables live).Testing
go build ./...,go vet ./...,golangci-lint(new-from-rev) — clean.pkg/configgentests pass.xcli lab up: infra start →migrate-xatu→ per-network setup ran against the local 2-node clusters.Dependency
infra migrate-xatu+ the database-agnostic migrations). Merge/deploy them together.🤖 Generated with Claude Code