fix: resolve migration timestamp collisions#30
Merged
ogazboiz merged 1 commit intoJun 19, 2026
Conversation
ogazboiz
approved these changes
Jun 19, 2026
ogazboiz
left a comment
Contributor
There was a problem hiding this comment.
this cleanly resolves all four migration timestamp collisions and the README notes on the fix are genuinely helpful, especially the bit about the pgmigrations tracking table for databases where the old-named migrations already ran. each collided pair has its second file bumped to the next number (007 to 008, 008 to 009, 016 to 017, 018 to 019), no duplicate prefixes remain and the ordering stays monotonic. i checked the dependency case too: 018 creates the index that 019 renames, and your order keeps 018 before 019 so that holds. build, typecheck and the full suite (215 tests) all pass locally. merging.
if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #22
Summary
Problem
Four pairs of migration files shared identical timestamp prefixes, making their apply order non-deterministic:
1777000000007loan-events-composite-indexes,unique-loan-status-events1778000000008quarantine-events,transaction-submissions1786000000016ensure-loan-events-loan-id-index,webhook-max-attempts1788000000018add-loan-events-missing-indexes,unified-contract-eventsThe
1788000000018pair was most critical:add-loan-events-missing-indexescreates indexes onloan_eventswhileunified-contract-eventsrenames that table tocontract_events. If they ran in the wrong order, the index creation would fail.Changes
Renamed one file per colliding pair to a unique, strictly-increasing timestamp:
1777000000007_unique-loan-status-events.js1777000000008_unique-loan-status-events.js1778000000008_transaction-submissions.js1778000000009_transaction-submissions.js1786000000016_webhook-max-attempts.js1786000000017_webhook-max-attempts.js1788000000018_unified-contract-events.js1788000000019_unified-contract-events.jsAll 27 timestamps are now unique and strictly increasing. The critical pair is correctly ordered —
add-loan-events-missing-indexes(1788000000018) runs beforeunified-contract-events(1788000000019).README — updated the core migrations table, added a migration naming convention section to prevent future collisions, and documented the exact SQL to fix
pgmigrationson existing databases after the rename.Verification
node-pg-migratecorrectly blocks with order-check errorpgmigrationsthen allowsmigrate:upto succeed