diff --git a/cashu/mint/migrations.py b/cashu/mint/migrations.py index 52c084f5..54a109b9 100644 --- a/cashu/mint/migrations.py +++ b/cashu/mint/migrations.py @@ -55,7 +55,7 @@ async def m002_add_balance_views(db: Database): SELECT SUM(amount) AS s FROM {table_with_schema(db, 'promises')} WHERE amount > 0 - ); + ) AS balance_issued; """) await conn.execute(f""" @@ -64,7 +64,7 @@ async def m002_add_balance_views(db: Database): SELECT SUM(amount) AS s FROM {table_with_schema(db, 'proofs_used')} WHERE amount > 0 - ); + ) AS balance_redeemed; """) await conn.execute(f""" @@ -183,9 +183,13 @@ async def m009_add_out_to_invoices(db: Database): # column in invoices for marking whether the invoice is incoming (out=False) or outgoing (out=True) async with db.connect() as conn: # we have to drop the balance views first and recreate them later - await conn.execute(f"DROP VIEW {table_with_schema(db, 'balance')}") - await conn.execute(f"DROP VIEW {table_with_schema(db, 'balance_issued')}") - await conn.execute(f"DROP VIEW {table_with_schema(db, 'balance_redeemed')}") + await conn.execute(f"DROP VIEW IF EXISTS {table_with_schema(db, 'balance')}") + await conn.execute( + f"DROP VIEW IF EXISTS {table_with_schema(db, 'balance_issued')}" + ) + await conn.execute( + f"DROP VIEW IF EXISTS {table_with_schema(db, 'balance_redeemed')}" + ) # rename column pr to bolt11 await conn.execute( @@ -211,6 +215,6 @@ async def m010_add_index_to_proofs_used(db: Database): async with db.connect() as conn: await conn.execute( "CREATE INDEX IF NOT EXISTS" - f" {table_with_schema(db, 'proofs_used')}_secret_idx ON" + " proofs_used_secret_idx ON" f" {table_with_schema(db, 'proofs_used')} (secret)" )