Skip to content

Commit

Permalink
mint: fix postgres migrations (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc authored Dec 2, 2023
1 parent 34a2e7e commit 74c9317
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cashu/mint/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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"""
Expand Down Expand Up @@ -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(
Expand All @@ -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)"
)

0 comments on commit 74c9317

Please sign in to comment.