Skip to content

Commit

Permalink
fix mint migrations for balance view (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc authored Nov 14, 2023
1 parent 2de9adf commit 286f850
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cashu/mint/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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;
""")


Expand Down

0 comments on commit 286f850

Please sign in to comment.