Skip to content

feat: implement soft delete support (#308)#458

Open
elenajoyce wants to merge 1 commit into
devEunicee:mainfrom
elenajoyce:feature/308-soft-delete-support
Open

feat: implement soft delete support (#308)#458
elenajoyce wants to merge 1 commit into
devEunicee:mainfrom
elenajoyce:feature/308-soft-delete-support

Conversation

@elenajoyce

Copy link
Copy Markdown

Summary

Adds soft-delete support to preserve data history while allowing logical deletion.

Changes

  • Migration 0004_soft_delete.sql — adds deleted_at TIMESTAMPTZ to merchants, payments, refunds; partial indexes on deleted_at IS NULL for query performance
  • api/src/services/softDelete.js:
    • softDelete(table, id) — sets deleted_at = NOW()
    • restore(table, id) — clears deleted_at (admin only)
    • softDeleteMerchantCascade(merchantAddress) — cascading soft-delete of merchant → payments → refunds in a single transaction
    • notDeletedClause(includeDeleted) — WHERE clause helper

Acceptance criteria

  • deleted_at timestamp column
  • Queries filter soft-deleted records by default (partial indexes + helper)
  • Admin can restore deleted records
  • Cascading soft deletes (transaction-safe)
  • Performance impact minimal (partial indexes)
  • Data recovery capability

Closes #308

- Add deleted_at column to merchants, payments, refunds via migration 0004
- Partial indexes on deleted_at IS NULL for query performance
- softDelete.js service: softDelete(), restore(), softDeleteMerchantCascade()
- Cascading soft delete runs in a single transaction
- notDeletedClause() helper for building filtered queries

Closes devEunicee#308
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@elenajoyce Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

#308 - Implement Soft Delete Support

1 participant