Skip to content

feat(database)!: squash the migrations into a 001 baseline, one migration per release (SPEC-032) - #117

Open
uw-sc wants to merge 5 commits into
cobaltcore-dev:mainfrom
uw-sc:feature/596-database-squash-the-migrations-restart-at-001-one-migration-per-release
Open

uw-sc wants to merge 5 commits into
cobaltcore-dev:mainfrom
uw-sc:feature/596-database-squash-the-migrations-restart-at-001-one-migration-per-release

Conversation

@uw-sc

@uw-sc uw-sc commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Squashes the 83 migrations into one generated baseline per backend, 001, which builds the same
schema and seed data. From now on a schema change is an unnumbered fragment in migrations/next/,
frozen into one migration per release (NNN_v<release>), so parallel branches no longer collide on
migration numbers.

Refs cobaltcore-dev/cloud-storage#596 · Spec: docs/specs/032-migration-squash-per-release/

What's in it

  • 001_baseline.{postgres,sqlite}, generated from the old history, which moves to
    internal/database/testdata/pre-squash/. On SQLite, five project_id columns are now NOT NULL
    instead of trigger-guarded.
  • make migration-fragment, make migrations-freeze; applied_migrations records each migration's
    checksum. Pre-squash and stale databases are refused with the way out: recreate.
  • CI: numbered migrations are immutable once on main; a v* tag with fragments fails.
  • Removed: scripts/upgrade-lightstack.sh, scripts/migrate-legacy-state.sh and the chart value
    realMode.legacyStatePath.
  • Also: deploy-single-node.sh migrates with lightstack-migrate up, and flaky test fixtures fixed.

Breaking

v0.7.0 is a fresh install: a database from an earlier Lightstack is refused. Recreate it as
docs/UPGRADING.md, "The migration squash", describes. A values file setting
realMode.legacyStatePath fails the chart schema.

Testing

  • Lint, unit tests (-race) and contract suite (325/0/12) pass on PostgreSQL and SQLite.
  • The baseline equals the old history on both backends: equivalence tests, plus a one-off per-migration
    check and a pg_dump / SQLite-catalog comparison against the base branch.

🤖 Generated with Claude Code

@uw-sc
uw-sc force-pushed the feature/596-database-squash-the-migrations-restart-at-001-one-migration-per-release branch from e6f52bb to a70be4a Compare November 26, 2026 10:25
@uw-sc uw-sc self-assigned this Nov 26, 2026
@uw-sc
uw-sc changed the base branch from feature/105 to main November 26, 2026 11:11
Uwe Schwaeke added 5 commits November 26, 2026 17:11
…-node deploy

The deploy script's migration step called `lightstack migrate`, a subcommand
the server never had: the server started in the foreground and the deployment
never finished. Its build step took a filter's exit status for the build's, so
a failed build passed, and it assumed make on hosts that may not have it.

- make build builds bin/lightstack-migrate beside the server.
- deploy-single-node.sh installs make when it is missing, checks the build's
  own status and both binaries, migrates with `lightstack-migrate up`, and
  reads its install directory from LIGHTSTACK_DIR. Sourcing it no longer runs
  main.
- test/deploy_single_node_test.sh covers the build and migration steps, and CI
  runs it.
- SCALING, UNIFIED_DEPLOYMENT and VXLAN_IMPLEMENTATION call
  `lightstack-migrate up` instead of the missing subcommand.
- test/migration_test.sh is removed: nothing ran it, it looked for the binary
  outside bin/, and the Go folder tests already make its file checks.

Found while working on cobaltcore-dev/cloud-storage#596.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
Packages run their tests in parallel against one database, and two kinds of
fixture made other packages' tests fail at random:

- The glance and cinder paging tests walked every row the shared seeded
  project could see, so another package's delete could remove the marker
  mid-walk. They now see only rows of their own, through a run-unique name and
  a project of the test's own.
- Nova fixtures inserted ports into the seeded project on a network but without
  a name. Neutron's port listing reads the name as a plain string, and one
  failed scan aborts the whole result, so its listing test got a 500 while such
  a port existed.

Every fixture port is now a whole port, with a name, a network and a MAC, as
Lightstack creates them. That includes the ports that could never reach the
listing (a project of their own, no network, or the listing test's own
package), so no future listing trips over them either.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
…tion per release

The 83 migrations up to 083 are replaced by one generated baseline per
backend, 001, which builds the same schema and seed data as the history; the
equivalence tests prove it on both backends. From now on a release adds at most
one migration, NNN_v<release>. Between releases a schema change is a fragment
in migrations/next/, named by its UTC creation time, ticket and purpose instead
of a number, so parallel changes never compete for one. The per-backend view
assembles the fragments into the open release migration.

- Every migration records its checksum in applied_migrations, whose presence
  marks a post-squash database. A database migrated before the squash is
  refused at start and by lightstack-migrate, untouched, with the way out:
  recreate it. A database that applied an earlier state of its version is
  refused as stale. On SQLite, five project_id columns are now NOT NULL in the
  schema, as on PostgreSQL.
- lightstack-migrate status names what a version is (baseline, release, open
  release migration) and reports PRE-SQUASH, STALE and NO DATABASE.
  lightstack-migrate freeze and make migrations-freeze freeze a release, all or
  nothing; make migration-fragment creates an empty fragment pair.
- CI fails a change to a numbered migration once it is on main, and a v* tag
  that still carries fragments.
- v0.7.0 is a fresh install: docs/UPGRADING.md keeps one section per release,
  and there is no re-stamp. scripts/upgrade-lightstack.sh is removed: it
  served bare-metal checkouts only, and its migration step could never finish.
- The old migrations survive as the generators' input in
  internal/database/testdata/pre-squash/. Comments and docs no longer cite
  their numbers, and the tests tied to a single old migration are retired.

BREAKING CHANGE: a database migrated by an earlier Lightstack is refused.
Recreate it; see docs/UPGRADING.md, "The migration squash".

Spec: docs/specs/032-migration-squash-per-release/
Refs: cobaltcore-dev/cloud-storage#596

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
The paragraph said a node sets the volume and snapshot reservations it left
behind to error at its startup. Since the periodic pass, a reservation whose
owner has stopped heartbeating is set to error without waiting for a restart,
as the code and the constitution say. The upgrade note that described this is
gone, so this paragraph is now where an operator reads it.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
scripts/migrate-legacy-state.sh and the chart's realMode.legacyStatePath
initContainer moved a node's state from the pre-rename root into the new one,
in place. v0.7.0 is a fresh install: the old images, volumes and instance
disks belong to the database it replaces, so moving them would only plant
orphans under the new root.

Removed: both scripts (the mover and its test, which nothing ran), and the
chart's value, schema entry, README row, initContainer, volume and unit tests.
The tasks of SPEC-032 record this and the fixes of the branch review.

BREAKING CHANGE: a values file that still sets realMode.legacyStatePath fails
the chart's schema; delete the key.

Refs: cobaltcore-dev/cloud-storage#596

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
@uw-sc
uw-sc force-pushed the feature/596-database-squash-the-migrations-restart-at-001-one-migration-per-release branch from a70be4a to 17b2225 Compare November 26, 2026 16:18
@uw-sc
uw-sc marked this pull request as ready for review November 26, 2026 16:18
@uw-sc
uw-sc requested a review from senolcolak November 26, 2026 16:18
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