Repository navigation
feat(db): add soft-delete pattern for core entities - #1816
Merged
github-actions[bot] merged 1 commit intoOct 17, 2026
Merged
github-actions[bot] merged 1 commit into
github-actions[bot] merged 1 commit into
Conversation
Add deleted_at TIMESTAMPTZ columns to 7 core entity tables with partial indexes for active/deleted filtering, a SoftDeleteHelper utility for consistent query building, and a filterActive function for patching existing queries. Changes: - Create db/migrations/011_soft_delete_core_entities.sql: adds deleted_at to subscriptions, transactions, users, merchants, loyalty, payment_methods, plans. Includes partial indexes for active and deleted rows, and -- @down rollback. - Create backend/shared/db/softDelete.ts: SoftDeleteHelper class with activeFilter, deletedFilter, softDeleteSql, restoreSql, purgeSql, findDeletedSql. SOFT_DELETE_HELPERS map for all tables. filterActive() function to patch SELECT queries. - Create backend/shared/db/__tests__/softDelete.test.ts: 16 test cases Acceptance criteria: - [x] Consistent filtering — filterActive() and SoftDeleteHelper provide uniform deleted_at IS NULL filtering across all repositories - [x] Restore path — restoreSql() sets deleted_at back to NULL - [x] Tested — 16 test cases covering all helpers and filterActive edge cases
|
@faith3310 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! 🚀 |
This branch was successfully deployed
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.
Summary
Resolves #1800
Adds
deleted_at TIMESTAMPTZcolumns to 7 core entity tables with partial indexes for active/deleted filtering, a SoftDeleteHelper utility for consistent query building, and a filterActive function for patching existing queries.Changes
db/migrations/011_soft_delete_core_entities.sql: adds deleted_at to subscriptions, transactions, users, merchants, loyalty, payment_methods, plans. Includes partial indexes and -- @down rollback.backend/shared/db/softDelete.ts: SoftDeleteHelper class, SOFT_DELETE_HELPERS map, filterActive() functionbackend/shared/db/__tests__/softDelete.test.ts: 16 test casesAcceptance Criteria