mirror of
https://github.com/aljazceru/nutshell.git
synced 2026-01-08 11:14:20 +01:00
mint: reenable balance views (#190)
This commit is contained in:
@@ -54,38 +54,38 @@ async def m001_initial(db: Database):
|
||||
"""
|
||||
)
|
||||
|
||||
# await db.execute(
|
||||
# f"""
|
||||
# CREATE VIEW {table_with_schema(db, 'balance_issued')} AS
|
||||
# SELECT COALESCE(SUM(s), 0) AS balance FROM (
|
||||
# SELECT SUM(amount) AS s
|
||||
# FROM {table_with_schema(db, 'promises')}
|
||||
# WHERE amount > 0
|
||||
# );
|
||||
# """
|
||||
# )
|
||||
await db.execute(
|
||||
f"""
|
||||
CREATE VIEW {table_with_schema(db, 'balance_issued')} AS
|
||||
SELECT COALESCE(SUM(s), 0) AS balance FROM (
|
||||
SELECT SUM(amount) AS s
|
||||
FROM {table_with_schema(db, 'promises')}
|
||||
WHERE amount > 0
|
||||
);
|
||||
"""
|
||||
)
|
||||
|
||||
# await db.execute(
|
||||
# f"""
|
||||
# CREATE VIEW {table_with_schema(db, 'balance_used')} AS
|
||||
# SELECT COALESCE(SUM(s), 0) AS balance FROM (
|
||||
# SELECT SUM(amount) AS s
|
||||
# FROM {table_with_schema(db, 'proofs_used')}
|
||||
# WHERE amount > 0
|
||||
# );
|
||||
# """
|
||||
# )
|
||||
await db.execute(
|
||||
f"""
|
||||
CREATE VIEW {table_with_schema(db, 'balance_redeemed')} AS
|
||||
SELECT COALESCE(SUM(s), 0) AS balance FROM (
|
||||
SELECT SUM(amount) AS s
|
||||
FROM {table_with_schema(db, 'proofs_used')}
|
||||
WHERE amount > 0
|
||||
);
|
||||
"""
|
||||
)
|
||||
|
||||
# await db.execute(
|
||||
# f"""
|
||||
# CREATE VIEW {table_with_schema(db, 'balance')} AS
|
||||
# SELECT s_issued - s_used AS balance FROM (
|
||||
# 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_used')} bu
|
||||
# );
|
||||
# """
|
||||
# )
|
||||
await db.execute(
|
||||
f"""
|
||||
CREATE VIEW {table_with_schema(db, 'balance')} AS
|
||||
SELECT s_issued - s_used AS balance FROM (
|
||||
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
|
||||
);
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
async def m003_mint_keysets(db: Database):
|
||||
|
||||
Reference in New Issue
Block a user