Skip to content

Accept trailing comments in deployment migrations - #174

Merged
31b4 merged 1 commit into
mainfrom
bug/173-migration-trailing-comments
Oct 20, 2026
Merged

31b4 merged 1 commit into
mainfrom
bug/173-migration-trailing-comments

Conversation

@31b4

@31b4 31b4 commented Oct 20, 2026

Copy link
Copy Markdown
Member

Closes #173

Summary

Deployment rejected 017-transaction-splits.sql because explanatory comments follow its final END;. The migration is valid; the runner incorrectly required the final text character to be a semicolon. In the reported run, investment links were already applied and recorded before validation stopped, and Workers/client were not deployed.

Accept trailing SQL comments without rewriting existing migration files, and prepare/validate every pending migration payload before any remote migration write.

Changes

  • Check the final SQL token while respecting line/block comments, quoted strings/identifiers and escaped quotes. Still reject missing terminators, comment-only files and unterminated strings/block comments; preserve SQL and append its history insert without an empty statement.
  • Read and prepare all pending payloads before initializing/writing migration history or submitting any migration. File-format errors in a later file cannot apply earlier migrations first.
  • Retain complete-name history tracking and post-import verification. A regression reproduces the reported partial-run state: recorded investment links are skipped, the commented split migration is submitted once, and a subsequent retry submits neither.
  • Add coverage for all 22 tracked migration payloads, comments, quoted semicolons and prevention of remote writes after a later validation failure. Clarify migration/retry documentation and the changelog.
  • No SQL migration files, database schema, financial behavior, dependencies or local deployment configuration are changed.

Verification

Using pinned Node 22.23.2:

  • All 29 deployment tests passed, including real API/MCP Wrangler dry-run bundles and the three new regressions. Those regressions failed before the fix.
  • All 19 tests across main-investment-merge, migrations and investment-epic-migrations passed against disposable Workers/D1.
  • All 22 generated migration-plus-history payloads executed on an empty disposable SQLite database with integrity/foreign-key checks and all history entries preserved.
  • git diff --check passed; existing .sql migration files are unchanged.

Retry after merge

Update the local main checkout and rerun the normal npm run deploy. The runner reads recorded migration names and skips 017-investment-transfer-links, then applies only missing files before deploying the selected applications. Do not remove migration history, manually replay the recorded migration or reset the database.

No remote database queries/writes, production deployment, or merge was performed while implementing/testing this fix.

@31b4
31b4 merged commit 60ff835 into main Oct 20, 2026
11 checks passed
@31b4
31b4 deleted the bug/173-migration-trailing-comments branch October 20, 2026 11:39
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.

Accept trailing SQL comments when validating deployment migrations

1 participant