Skip to content

Commit f42b279

Browse files
committed
chore(db): Add migration to clean up inconsistent shares
This commit introduces a new data migration to address inconsistencies in existing expense data. It targets expenses where the is set to 'EVENLY' but the associated in the table are not normalized to 1. The migration ensures that all such expenses are corrected, guaranteeing data integrity and preventing calculation errors in features like CSV exports. This is a one-time cleanup that will be applied automatically when running .
1 parent 092635d commit f42b279

File tree

1 file changed

+11
-0
lines changed
  • prisma/migrations/20250701155133_cleanup_evenly_shares

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- This migration cleans up existing data where the split mode is 'EVENLY'
2+
-- but the shares are not set to 1. This ensures data consistency for
3+
-- all expenses that should be split equally.
4+
5+
UPDATE "ExpensePaidFor"
6+
SET "shares" = 1
7+
WHERE "expenseId" IN (
8+
SELECT "id"
9+
FROM "Expense"
10+
WHERE "splitMode" = 'EVENLY'
11+
);

0 commit comments

Comments
 (0)