Skip to content

fix(db): idempotent refund_accounts currency migration for re-apply - #679

Merged
5ran6 merged 1 commit into
mainfrom
agent/fix-refund-migration-idempotent-bc42
Aug 17, 2026
Merged

fix(db): idempotent refund_accounts currency migration for re-apply#679
5ran6 merged 1 commit into
mainfrom
agent/fix-refund-migration-idempotent-bc42

Conversation

@5ran6

@5ran6 5ran6 commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Jira Issue

Jira Issue: (Atlassian MCP not authenticated — please file a KAN Bug labeled noblocks and update this link)

Description

After #678 retimestamped migrations, main migrate tried to apply 20260817180000_refund_accounts_per_currency.sql and failed:

ERROR: relation "refund_accounts_one_per_wallet_currency" already exists (SQLSTATE 42P07)

Notices showed currency already exists and refund_accounts_one_per_wallet already gone — the #667 DDL was applied to production (stable path) but never recorded under the new version id. The identity migrations never ran because this file aborted first.

Make the unique-constraint add idempotent via a pg_constraint existence check (same pattern as 20260817180200). Column add / old-constraint drop were already safe.

Self-review

  • Reviewed against failing migrate log
  • CodeRabbit / CI green

References

Testing

  • After merge, main migrate should skip the existing unique constraint, record 20260817180000, then apply 2026081718010020260817180400

  • Confirm no 42P07 on refund_accounts

  • This change adds test coverage for new/changed/fixed functionality

Staging

  • Staging noblocks checked (wallet and transaction flows)

Checklist

  • I have added documentation and tests for new/changed functionality in this PR
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not main
  • If this PR adds a database migration, it follows expand/contract: the new code works against the pre-migration schema, the currently deployed code keeps working against the post-migration schema, and destructive changes (drops, renames, tightened constraints) are deferred until the old application version is no longer serving — migrations are applied around the deploy, not strictly before or after it

By submitting a PR, I agree to Paycrest's Contributor Code of Conduct and Contribution Guide.

Open in Web Open in Cursor 

Production already has currency + refund_accounts_one_per_wallet_currency
from the stable-only #667 apply, but the retimestamped 20260817180000 was
not in the migrate ledger. Guard the unique constraint with a pg_constraint
check so db push can record the version and continue to the identity
migrations.

Co-authored-by: Francis Ocholi <5ran6@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bf2bfb64-3e34-4bb6-9e0e-90698e977408

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@5ran6
5ran6 marked this pull request as ready for review August 17, 2026 17:39
@5ran6
5ran6 merged commit 270e94f into main Aug 17, 2026
3 checks passed
@5ran6
5ran6 deleted the agent/fix-refund-migration-idempotent-bc42 branch August 17, 2026 17:41
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.

2 participants