Trigger to default fiat conversion on

Like all the other wallets
This commit is contained in:
arcbtc 2024-12-18 20:40:32 +00:00
parent d234ab12d8
commit 3dd1c6992b

View File

@ -684,3 +684,22 @@ async def m029_create_audit_table(db: Connection):
);
"""
)
async def m030_add_currency_to_wallet(db: Connection):
"""
Setting currency to default is heavy, so easier just to add a trigger.
"""
await db.execute(
"""
CREATE TRIGGER IF NOT EXISTS set_default_currency
AFTER INSERT ON wallets
FOR EACH ROW
WHEN NEW.currency IS NULL
BEGIN
UPDATE wallets
SET currency = 'USD'
WHERE id = NEW.id;
END;
"""
)