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):
|
async def m006_add_invoice_expiry_to_apipayments(db):
|
||||||
"""
|
"""
|
||||||
Adds invoice expiry column to apipayments and precomputes them for
|
Adds invoice expiry column to apipayments.
|
||||||
existing entries
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
await db.execute("ALTER TABLE apipayments ADD COLUMN expiry TIMESTAMP")
|
await db.execute("ALTER TABLE apipayments ADD COLUMN expiry TIMESTAMP")
|
||||||
except OperationalError:
|
except OperationalError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
async def m007_set_invoice_expiries(db):
|
||||||
|
"""
|
||||||
|
Precomputes invoice expiry for existing pending incoming payments.
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
rows = await (
|
rows = await (
|
||||||
await db.execute(
|
await db.execute(
|
||||||
|
|
@ -232,7 +236,7 @@ async def m006_add_invoice_expiry_to_apipayments(db):
|
||||||
invoice.date + invoice.expiry
|
invoice.date + invoice.expiry
|
||||||
)
|
)
|
||||||
logger.info(
|
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(
|
await db.execute(
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,8 @@ class Database(Compat):
|
||||||
import psycopg2 # type: ignore
|
import psycopg2 # type: ignore
|
||||||
|
|
||||||
def _parse_timestamp(value, _):
|
def _parse_timestamp(value, _):
|
||||||
|
if value is None:
|
||||||
|
return None
|
||||||
f = "%Y-%m-%d %H:%M:%S.%f"
|
f = "%Y-%m-%d %H:%M:%S.%f"
|
||||||
if not "." in value:
|
if not "." in value:
|
||||||
f = "%Y-%m-%d %H:%M:%S"
|
f = "%Y-%m-%d %H:%M:%S"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue