separate migrations
This commit is contained in:
parent
00a3bd9ce7
commit
3bb11dc487
2 changed files with 9 additions and 3 deletions
|
|
@ -197,14 +197,18 @@ async def m005_balance_check_balance_notify(db):
|
|||
|
||||
async def m006_add_invoice_expiry_to_apipayments(db):
|
||||
"""
|
||||
Adds invoice expiry column to apipayments and precomputes them for
|
||||
existing entries
|
||||
Adds invoice expiry column to apipayments.
|
||||
"""
|
||||
try:
|
||||
await db.execute("ALTER TABLE apipayments ADD COLUMN expiry TIMESTAMP")
|
||||
except OperationalError:
|
||||
pass
|
||||
|
||||
|
||||
async def m007_set_invoice_expiries(db):
|
||||
"""
|
||||
Precomputes invoice expiry for existing pending incoming payments.
|
||||
"""
|
||||
try:
|
||||
rows = await (
|
||||
await db.execute(
|
||||
|
|
@ -232,7 +236,7 @@ async def m006_add_invoice_expiry_to_apipayments(db):
|
|||
invoice.date + invoice.expiry
|
||||
)
|
||||
logger.info(
|
||||
f"Mirgraion: {i}/{len(rows)} setting expiry of invoice {invoice.payment_hash} to {expiration_date}"
|
||||
f"Mirgraion: {i+1}/{len(rows)} setting expiry of invoice {invoice.payment_hash} to {expiration_date}"
|
||||
)
|
||||
await db.execute(
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ class Database(Compat):
|
|||
import psycopg2 # type: ignore
|
||||
|
||||
def _parse_timestamp(value, _):
|
||||
if value is None:
|
||||
return None
|
||||
f = "%Y-%m-%d %H:%M:%S.%f"
|
||||
if not "." in value:
|
||||
f = "%Y-%m-%d %H:%M:%S"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue