Skip to content

Add migrate CLI command with datastore:// storage rewrite (Phase 2, #347) - #391

Merged
em3s merged 2 commits into
mainfrom
feat/issue-347-migration-scripts
Jul 23, 2026
Merged

em3s merged 2 commits into
mainfrom
feat/issue-347-migration-scripts

Conversation

@em3s

@em3s em3s commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a native migrate CLI command to seed metadata into HBase for Phase 2 of #347, replacing the earlier dev/*.py prototype scripts (never merged). Each label's storage reference is rewritten to a datastore:// URI during migration, so the seeded metadata is valid against the new storage model (#398).

Once migration completes, MySQL is effectively dead. Every key exists in HBase, so the overlay (#390) always returns the HBase value and never falls through to MySQL. No code change needed — MySQL just stops being read. That's the gate for Phase 3.

I rebuilt the branch on current main: it previously stacked on #390's overlay commits, which have since been squash-merged. Re-verifying against main surfaced three contract drifts, fixed here: duplicates surface as 400 (not 409), only HBASE storages have a datastore:// equivalent, and label caches were dropped from the replay body.

Related: #347, #390, #398

Changes

  • cli/internal/command/migrate.go — new command, two phases:
    • migrate plan [-o <file>] reads databases/tables/aliases (sys/origin skipped) and writes a {path, body, label} plan
    • migrate apply [-i <file>] replays each entry; duplicates are skipped so re-runs are idempotent
  • Duplicate detection matches the server's actual contract: the v2 DDL path maps failOnExist duplicates to 400 with an "already exists" message (AbstractLabel → ExceptionController) — there is no 409. A plain 409 is still treated as a skip.
  • Storage rewrite is HBASE-only: HBASE → datastore://<namespace>/<table>. The engine resolves every datastore:// URI except the reserved __sys__ metastore as an HBase namespace/table, so minting sentinel URIs for JDBC/LOCAL would create labels the server can't route. migrate plan fails fast, with the reason, if a label references a non-HBASE storage. References that are already datastore:// URIs pass through unchanged.
  • Label caches are carried into the replay body (previously dropped silently).
  • client.PostRaw / http.PostForResult — POST returning status + raw body, so apply can key on the error message; failures print the server response
  • command_type.go, actionbase_runner.go — register the command
  • Unit tests for the storage→URI conversion, the tableBody rewrite paths, duplicate matching, and the sys/origin filter

How to Test

cd cli && go test ./...
ACT_HOST=https://ab.example.com ACT_API_KEY=<key> actionbase -e "migrate plan"
# review migration-run.json, then
ACT_HOST=https://ab.example.com ACT_API_KEY=<key> actionbase -e "migrate apply"

migrate apply exits non-zero if any entry fails.

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Opus 4.8, Claude Fable 5

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jul 3, 2026
@em3s em3s changed the title feat(dev): metadata migration scripts for Phase 2 (#347) Add metadata migration scripts (Phase 2, #347) Jul 3, 2026
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 11, 2026
@em3s em3s changed the title Add metadata migration scripts (Phase 2, #347) Add migrate CLI command with datastore:// storage rewrite (Phase 2, #347) Jul 11, 2026
@em3s em3s self-assigned this Jul 15, 2026
Base automatically changed from feat/issue-347-overlay-metastore-label to main July 16, 2026 07:26
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jul 16, 2026
em3s and others added 2 commits July 23, 2026 23:53
)

Rebuilt on current main: the previous branch stacked on #390's overlay
commits, which were squash-merged, leaving only the cli/ changes as the
actual contribution.

Co-Authored-By: Claude Fable 5 <[email protected]>
…ewrite, carry caches

The v2 DDL path maps duplicate creates to 400 with an "already exists"
message (there is no 409), so apply keys on that to stay idempotent.
The engine resolves every datastore:// URI except the __sys__ metastore
as an HBase namespace/table, so the __jdbc__/__local__ sentinel URIs
would create labels the server cannot route — plan now fails fast when
a label references a non-HBASE storage. Label caches were silently
dropped; the plan now carries them.

Co-Authored-By: Claude Fable 5 <[email protected]>
@em3s
em3s force-pushed the feat/issue-347-migration-scripts branch from 2eae31f to d95eba1 Compare July 23, 2026 15:05
@em3s

em3s commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Optimistic

@em3s
em3s merged commit ce28119 into main Jul 23, 2026
2 checks passed
@em3s
em3s deleted the feat/issue-347-migration-scripts branch July 23, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant