Skip to content

fix: Exit with code 1 when the maintenance role fails to apply migrations - #5719

Merged
FXschwartz merged 1 commit into
serverpod:mainfrom
FXschwartz:FXschwartz/maintenance-role-exits-0-after-a-failed-migratio
Sep 17, 2026
Merged

FXschwartz merged 1 commit into
serverpod:mainfrom
FXschwartz:FXschwartz/maintenance-role-exits-0-after-a-failed-migratio

Conversation

@FXschwartz

@FXschwartz FXschwartz commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Running --role maintenance --apply-migrations exited with code 0 after a failed migration in every run mode except development, so CI jobs passed and deployed against an unmigrated database. #3852 made the exit on a failed integrity check development-only to keep running servers up, but the condition ignored the role and took the exit code away from the maintenance role, which has no other way to report the result.

  • A maintenance run with --apply-migrations or --apply-repair-migration now sets the exit code to 1 when applying fails or the database doesn't match the target state afterward.
  • Monolith and serverless behavior is unchanged, outside development they log the failure and keep starting.
  • The failure still travels as an ExitException.

Closes #5709

Docs PR - serverpod/serverpod_docs#851

Pre-launch Checklist

  • I read the Contribute page and followed the process outlined there for submitting PRs.
  • This update contains only one single feature or bug fix and nothing else. (If you are submitting multiple fixes, please make multiple PRs.)
  • I read and followed the Dart Style Guide and formatted the code with dart format.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.
  • I added new tests to check the change I am making.
  • All existing and new tests are passing.
  • Any breaking changes are documented below.

If you need help, consider asking for advice on the discussion board.

Breaking changes

None

@FXschwartz
FXschwartz requested a review from a team September 17, 2026 18:21
@FXschwartz FXschwartz self-assigned this Sep 17, 2026
@FXschwartz FXschwartz changed the title Exit with code 1 when the maintenance role fails to apply migrations. fix: Exit with code 1 when the maintenance role fails to apply migrations Sep 17, 2026

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@FXschwartz
FXschwartz merged commit 9b20ff8 into serverpod:main Sep 17, 2026
958 of 961 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maintenance role exits 0 after a failed migration outside development

2 participants