Skip to content

fix: preserve migration headers after failed commit - #273

Merged
benjie merged 4 commits into
graphile:mainfrom
sean0407:codex/restore-commit-message-header
Oct 14, 2026
Merged

benjie merged 4 commits into
graphile:mainfrom
sean0407:codex/restore-commit-message-header

Conversation

@sean0407

Copy link
Copy Markdown

Fixes #119.

Summary

- await writeCurrentMigration(..., body)
+ await writeCurrentMigration(..., serializeMigration(body, headers))

When commit fails, parseMigrationText has separated migration headers from the SQL body. Restoring only the body drops the --! Message: header from current.sql. This change serializes the parsed headers with the body before restoring it.

Open PR #262 separately restores --!include directives in this rollback path; this change covers the distinct loss of migration headers.

Evidence

  • Before: A failing commit with --! Message: test-migration restored current.sql without the header.
  • After: The regression test verifies the restored file exactly matches the original and the failed committed migration is removed.

Validation

  • yarn test:only __tests__/commit.test.ts — 14 passed.
  • yarn prettier:check — passed.

Merge Danger

Door: Two-way

Blast Radius: Low

The change applies only to restoring the current migration after a failed commit.

@benjie benjie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for spotting the issue! Rather than recreating the text with headers, I've just fixed the issue: use the original text that we read.

@benjie
benjie merged commit 7f317a0 into graphile:main Oct 14, 2026
9 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 14, 2026
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.

Message header lost on commit error

2 participants