Skip to content

Add support for checkpoints. - #2

Open
ioquatix wants to merge 1 commit into
mainfrom
implement-checkpoints
Open

ioquatix wants to merge 1 commit into
mainfrom
implement-checkpoints

Conversation

@ioquatix

Copy link
Copy Markdown
Member

Summary

Adds support for checkpoints: absolute snapshots of state, in contrast to regular migrations which are deltas.

  • A checkpoint migration is identified by the checkpoint marker in its name, for example 20260101000000-checkpoint.rb.
  • Migrate::Controller#migrate!(checkpoint:):
    • checkpoint: true — apply the most recent checkpoint, then only the migrations which sort after it.
    • checkpoint: "name" — apply the checkpoint with that name, then the migrations which sort after it. Raises RuntimeError if it does not exist.
    • checkpoint: nil (default) — full replay: every non-checkpoint migration is applied and checkpoint files are skipped, yielding the same final state as before.
  • Migrate::Migration#checkpoint mirrors #migrate and delegates to the migrator's checkpoint method.
  • Migrate::Provider#checkpoint raises NotImplementedError until implementations override it.
  • The bake migrate task accepts a checkpoint: keyword and passes it through.

Checkpoints are optional, so existing setups are unaffected.

Tests

Covers: full replay (checkpoints skipped), latest checkpoint, pinned checkpoint, checkpoint not found, and FakeCheckpointMigrator receiving the checkpoint call with the expected arguments.

Signed-off-by: Samuel Williams <samuel.williams@oriontransfer.co.nz>

This branch has not been deployed

No deployments
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