diff --git a/postgres/schema/0018_reconciled-on.sql b/postgres/schema/0018_reconciled-on.sql index a8adb68..42a16ed 100644 --- a/postgres/schema/0018_reconciled-on.sql +++ b/postgres/schema/0018_reconciled-on.sql @@ -1,5 +1,12 @@ -- +goose Up ALTER TABLE accounts ADD COLUMN last_reconciled date NULL; +UPDATE accounts +SET last_reconciled = ( + SELECT MAX(transactions.date) + FROM transactions + WHERE transactions.account_id = accounts.id + AND transactions.status = 'Reconciled' +); -- +goose Down ALTER TABLE accounts DROP COLUMN last_reconciled; \ No newline at end of file