Skip to content

feat(install): apply an incompatible migration on the Owner's approval after a snapshot - #93

Open
mrgoonie wants to merge 1 commit into
mainfrom
claude/owner-approved-migration
Open

mrgoonie wants to merge 1 commit into
mainfrom
claude/owner-approved-migration

Conversation

@mrgoonie

Copy link
Copy Markdown
Contributor

Fixes #76.

What

On an existing store, a migration that is not backward compatible (12 today) can now be applied, but only on the Owner's approval and only after a snapshot:

  • sisf up --approve-migrations=<versions>. The approval must name exactly the incompatible migrations pending; this is checked under the migration lock. A partial set, an extra version or a different set is refused with APPROVAL_REQUIRED, and nothing is applied. With nothing incompatible pending, the flag changes nothing.
  • Snapshot first, to <dir>/backups/ (dir 0700, file 0600):
    • Standalone: VACUUM INTO of the SQLite file.
    • Docker: pg_dump --format=custom through the state container, before the state-bootstrap step.
    • If the snapshot fails, the upgrade stops before migrating.
  • Audit entry state.migrate_approved, recording actor owner:local, the versions and the snapshot name.
  • Docs:
    • maintenance guide: procedure and restore, for both SQLite and Docker;
    • release notes;
    • a troubleshooting row.

Decision (delegated)

The Owner delegated the ADR 0013 decision ("tự quyết sao cho tốt nhất rồi ghi lại quyết định"). It is recorded in the ADR and on #76.

  • The Owner approves on the host rather than through the action service. No surface can run while an incompatible migration is pending, so this is a deliberate surface-parity exception, limited to install-time steps.
  • The self-publish gate stays proposed. Today SISF self-publishes only application units, so no self-published release carries a store migration yet.

Shared-contract change

pkg/state/state.go changes:

  • new MigrateOptions.Approved []int;
  • new state.ApprovesExactly.

The Migrator interface is unchanged.

Verification

  • go build ./..., go vet, gofmt: clean. golangci-lint run: 0 issues.
  • go test -race ./...: green.
    • tests/acceptance passed in a run of its own (319s). In the full local run it hit the default 10-minute timeout while the PostgreSQL suite was running alongside it.
  • The PostgreSQL suite (SISF_TEST_PG_DSN, postgres:16) passed for pkg/state/... and internal/install/....
  • Docker dump and restore were tested by hand against postgres:16 with docker exec:
    • pg_dump custom format, then dropdb/createdb/pg_restore;
    • rows, schema version, row policies and grants all came back.
    • This was not run through a whole Docker install, and the docs say so.

…l after a snapshot

sisf up --approve-migrations=<versions> lets the Owner approve exactly the
incompatible migrations pending on an existing store. Before migrating, the
store is snapshotted to <dir>/backups: VACUUM INTO for SQLite, pg_dump through
the state container in Docker mode. A failed snapshot stops the upgrade, and
the applied approval is written to the audit log.

Fixes #76

Signed-off-by: Goon <duy@wearetopgroup.com>
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.

Owner-approved path for a schema migration that is not backward compatible

1 participant