From d107b16f40cec7be73793ca8adc91464719ddc69 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:50:33 -0300 Subject: [PATCH] fix mint migrations for balance view --- cashu/mint/migrations.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cashu/mint/migrations.py b/cashu/mint/migrations.py index 5b9270ba..2293ace7 100644 --- a/cashu/mint/migrations.py +++ b/cashu/mint/migrations.py @@ -52,19 +52,19 @@ async def m002_add_balance_views(db: Database): await conn.execute(f""" CREATE VIEW {table_with_schema(db, 'balance_issued')} AS SELECT COALESCE(SUM(s), 0) AS balance FROM ( - SELECT SUM(amount) + SELECT SUM(amount) AS s FROM {table_with_schema(db, 'promises')} WHERE amount > 0 - ) AS s; + ); """) await conn.execute(f""" CREATE VIEW {table_with_schema(db, 'balance_redeemed')} AS SELECT COALESCE(SUM(s), 0) AS balance FROM ( - SELECT SUM(amount) + SELECT SUM(amount) AS s FROM {table_with_schema(db, 'proofs_used')} WHERE amount > 0 - ) AS s; + ); """) await conn.execute(f""" @@ -73,7 +73,7 @@ async def m002_add_balance_views(db: Database): SELECT bi.balance AS s_issued, bu.balance AS s_used FROM {table_with_schema(db, 'balance_issued')} bi CROSS JOIN {table_with_schema(db, 'balance_redeemed')} bu - ) AS balance; + ) AS balance; """)