Skip to content

feat(cli): migration ingest stores local bundles without planning - #77

Merged
davdxpx merged 1 commit into
mainfrom
feat/cli-migration-ingest
Nov 11, 2026
Merged

davdxpx merged 1 commit into
mainfrom
feat/cli-migration-ingest

Conversation

@davdxpx

@davdxpx davdxpx commented Nov 11, 2026

Copy link
Copy Markdown
Owner

What

Adds exponetdb migration ingest [migration…]: it submits the exact bytes of the named local bundles (default: every local bundle) to the existing POST /projects/{projectId}/bundles (migration.bundle.ingest, scope migrations.plan) and prints each migration's id, name, revision, status and apply checksum. For a verify_revision it names the next command, exponetdb migration verify <id> --revision <n> --target <target>. It makes no plan, applies nothing and reads no target.

Why

A verify.sql corrected after its migration was applied could not be stored anywhere:

  • migration plan ingests inside the planning transaction and then refuses an applied migration with MIGRATION_ALREADY_APPLIED; the refusal rolls the ingestion back, so no revision exists (checked on REOSA staging with the same checksum: migration verify --revision 2 stayed NOT_FOUND).
  • Planning on a scratch target does not help either: scratch targets lack the project's baseline (MIGRATION_DEPENDENCY_UNKNOWN).
  • The server route and its engine code (ingestBundles in packages/migrations-engine/src/store.ts, status verify_revision) were complete, but neither the CLI nor the MCP called it.

On REOSA this left two migrations applied on staging with verification failed only because of a verify.sql bug, and production refuses them without break-glass. exponetdb-docs/04-migrations/verification.md already described step 2 ("the new bundle revision is ingested") without a way to do it.

Changes

  • apps/cli/src/commands/migration.ts: the new command, the project id resolved from the project path like project link does (projectRef, now exported from registry.ts).
  • exponetdb-docs/04-migrations/verification.md: how a verify revision is stored, with the observed migration plan behavior marked [OBSERVED].
  • exponetdb-docs/15-cli/reference.md: regenerated (bun run reference).
  • apps/cli/test/migration-ingest.test.ts: seven tests against the fake API.

No server, contract or Control Store change; no constitution exception.

Checked

  • bun run check, tsc of apps/cli, the whole CLI test suite (231 tests, 7 new), bun run boundaries, bun run secrets, bun run verify:generated: all green (Node 24.22.1; the WSL default Node is 18).
  • The new tests cover: exact bytes of the named bundle only, every bundle when no id is given, no migration verify hint for stored/unchanged, no request other than GET /projects and the ingest POST, an unknown id refused before anything is sent, a server refusal shown with a non-zero exit, and the help text naming the scope and action.

Not checked

  • No run against db.exponet.cloud. The first real use needs a sign-in with migrations.plan:
exponetdb login --server https://db.exponet.cloud --scope "targets.read migrations.read migrations.plan"
exponetdb migration ingest <migration id>        # in the project directory
exponetdb migration verify <migration id> --revision <n> --target reosa/platform/staging
  • That the server stores a changed verify.sql of an already applied checksum as verify_revision is read from ingestBundles (an existing revision with the same apply checksum), not yet observed end to end.
  • The packed CLI that REOSA vendors (vendor/exponetdb/exponetdb-cli-0.6.0.tgz there) is not rebuilt here, and the CLI version is not changed.

A verify.sql corrected after a migration was applied could not be stored:
migration plan ingests inside the planning transaction and then refuses an
applied migration with MIGRATION_ALREADY_APPLIED, so nothing is kept, and no
command called the existing ingestBundles route.

migration ingest submits the exact bytes of the named local bundles (default:
all) to POST /projects/{projectId}/bundles (migration.bundle.ingest, scope
migrations.plan), prints each migration's status and revision, and names the
migration verify --revision command to run next for a verify_revision. It
plans, applies and reads no target.
@davdxpx
davdxpx marked this pull request as ready for review November 11, 2026 21:02
@davdxpx
davdxpx merged commit 41aaa2b into main Nov 11, 2026
15 of 18 checks passed
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.

1 participant