Skip to content

Conversation

@thomas-waite
Copy link
Contributor

@thomas-waite thomas-waite commented Feb 3, 2026

Use explicit state-based pattern in migration controller

Refactors the migration controller to use explicit state-based handling with a match statement, making the logic clearer and simpler.

Changes

  • Refactored state handling: Replaced sequential if-statements with explicit match on MigrationStatus, making each state's behavior clear and self-documenting
  • Removed BlockedUserAction state: Simplified from 5 states to 4. There's no need for a "blocked on user action" state as all planned migrations are non-interactive.
  • Updated docs: Added a README that describes the states and transitions
  • Added more comprehensive state transition tests

Testing

All 23 tests pass in ~6.3 seconds. New tests verify:

  • Terminal states (Succeeded, FailedTerminal) are skipped correctly
  • Retry timing only affects FailedRetryable state
  • InProgress without timestamp is treated as stale
  • State transitions work as documented

@thomas-waite thomas-waite changed the title [WIP] feat: Skip BlockedUserAction state, detect stale InProgress state [WIP] feat: Remove BlockedUserAction state, detect stale InProgress state Feb 3, 2026
@thomas-waite thomas-waite changed the title [WIP] feat: Remove BlockedUserAction state, detect stale InProgress state feat: Remove BlockedUserAction state, detect stale InProgress state Feb 3, 2026
@thomas-waite thomas-waite marked this pull request as ready for review February 3, 2026 23:59
@thomas-waite thomas-waite changed the base branch from main to feat/timeout-migration-protection February 3, 2026 23:59
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d1940054fe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@thomas-waite thomas-waite changed the title feat: Remove BlockedUserAction state, detect stale InProgress state refactor: Use explicit state-based pattern in migration controller Feb 4, 2026
@thomas-waite
Copy link
Contributor Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d49bb3ffb6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +206 to +210
// Fresh InProgress - skip to avoid concurrent execution
info!(
"Migration {migration_id} currently in progress, skipping"
);
summary.skipped += 1;

Choose a reason for hiding this comment

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

P2 Badge Retry InProgress after restart instead of skipping

Skipping a “fresh” InProgress entry means a crash followed by a quick restart leaves the migration stuck for the entire session: run_migrations only executes on app start (per migration/README.md), so once you skip here there is no later retry when the stale window elapses. This regresses crash recovery—if the app restarts within 5 minutes, the migration will never retry until another app restart after the stale threshold.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's fine

paolodamico
paolodamico previously approved these changes Feb 6, 2026
@thomas-waite thomas-waite changed the base branch from feat/timeout-migration-protection to main February 10, 2026 22:48
@thomas-waite thomas-waite dismissed paolodamico’s stale review February 10, 2026 22:48

The base branch was changed.

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.

2 participants