fix mint migrations for balance view (#361)

This commit is contained in:
callebtc
2023-11-14 16:25:27 -03:00
committed by GitHub
parent 2de9adf362
commit 286f850de8

View File

@@ -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;
""")