From 0b50ba0f8298ff87e3f6bf8587d65387bfd1fbde Mon Sep 17 00:00:00 2001 From: padreug Date: Sat, 8 Nov 2025 10:14:38 +0100 Subject: [PATCH] Removes legacy equity accounts Removes generic equity accounts that are no longer necessary due to the user-specific equity model introduced by the castle extension. Specifically, it removes "Equity:MemberEquity" and "Equity:RetainedEarnings" accounts. --- migrations.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/migrations.py b/migrations.py index cf4222f..3527ac9 100644 --- a/migrations.py +++ b/migrations.py @@ -516,3 +516,28 @@ async def m013_remove_parent_only_accounts(db): "DELETE FROM accounts WHERE name = :name", {"name": "Equity"} ) + + +async def m014_remove_legacy_equity_accounts(db): + """ + Remove legacy generic equity accounts that don't fit the user-specific equity model. + + The castle extension uses dynamic user-specific equity accounts (Equity:User-{user_id}) + created automatically when granting equity eligibility. Generic equity accounts like + MemberEquity and RetainedEarnings are not needed. + + Removes: + - Equity:MemberEquity + - Equity:RetainedEarnings + """ + # Remove Equity:MemberEquity + await db.execute( + "DELETE FROM accounts WHERE name = :name", + {"name": "Equity:MemberEquity"} + ) + + # Remove Equity:RetainedEarnings + await db.execute( + "DELETE FROM accounts WHERE name = :name", + {"name": "Equity:RetainedEarnings"} + )