Skip to content

[Backend] Four pairs of migrations share identical timestamps, making apply order non-deterministic #22

Description

@grantfox-oss

Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0

Why this matters

migrations/ contains colliding prefixes 1777000000007, 1778000000008, 1786000000016 and 1788000000018. The 1788000000018 pair is the most dangerous: unified-contract-events.js renames loan_events to contract_events while add-loan-events-missing-indexes.js creates indexes on loan_events, so order determines whether the migration succeeds.

Acceptance criteria

  • Rename one file in each colliding pair to a unique, strictly-increasing timestamp
  • Verify a clean npm run migrate:up on an empty DB applies all migrations in a deterministic, correct order
  • Confirm the rename does not break the already-applied set on an existing DB (pgmigrations table names)
  • Document the convention to avoid future timestamp collisions

Files to touch

  • migrations/1788000000018_unified-contract-events.js
  • migrations/1788000000018_add-loan-events-missing-indexes.js
  • migrations/1777000000007_unique-loan-status-events.js
  • migrations/1786000000016_webhook-max-attempts.js

Out of scope

  • Rewriting the migration logic itself
  • Squashing historical migrations

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't workinghardAdvanced / high-difficulty issue

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions