Skip to content

Conversation

@morgo
Copy link
Collaborator

@morgo morgo commented Jan 20, 2026

A Pull Request should be associated with an Issue.

We wish to have discussions in Issues. A single issue may be targeted by multiple PRs.
If you're offering a new feature or fixing anything, we'd like to know beforehand in Issues,
and potentially we'll be able to point development in a particular direction.
Further notes in https://github.com/block/spirit/blob/main/.github/CONTRIBUTING.md

Fixes #534

The checks system in migrations moves some of the non-mutating inspections of configuration, state, options into a separate package. Because it depends on Resources which are specific to migrations, it is hard to repurpose this to moves. So I've moved it to pkg/migration/check/ and created a new pkg/move/check with similar semantics.

Full list of changes:

  • Moves isMinimalRBRTestRunner to testutils.IsMinimalRBRTestRunner and uses it for all packages as a way to detect if buffered tests should run (replacing move.settingsCheck).
  • Moves pkg/check to pkg/migration/check/
  • Creates pkg/move/check, and adds a new check for configuration
  • Functionality from pkg/move/runner.go to determine if a resume is possible or a new migration is moved into the checks system (target_state and resume_state).

})

// Create checkpoint table for remaining tests
_, err = sourceDB.ExecContext(t.Context(), `CREATE TABLE resume_src._spirit_checkpoint (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it potentially annoying for future you to not create the checkpoint with the actual checkpoint code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be a cyclical dependency because that would require runner.go:createCheckpointTable() to be called, which needs to import the move package.

If I extracted createCheckpointTable() to its own package for checkpoints that would make this possible - but there is not too much benefit to that right now.

err := r.SourceDB.QueryRowContext(ctx,
"SELECT 1 FROM information_schema.TABLES WHERE table_schema = ? AND table_name = ?",
r.SourceConfig.DBName, checkpointTableName).Scan(&checkpointExists)
if err == sql.ErrNoRows {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anything in the checkpoint table itself need to be checked at this stage?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could, but restoring the checkpoint is also able to return an error in pkg/move/runner.go:resumeFromCheckpoint()

My preference is not to because if I change the checkpoint format (it happens) the code is non-dry. This is because the check should only check and is not expected to load or mutate structures.

If I move checkpoints to a separate package, that would be a different argument though; they could call the same helper.

@morgo morgo enabled auto-merge January 20, 2026 20:59
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.

Add checks system of at least configuration check for MoveTables

2 participants