feat: add created_at time to links (#46)

closes #16
This commit is contained in:
dni ⚡ 2024-08-30 06:17:26 +02:00 committed by GitHub
commit e2f97f05dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 55 additions and 31 deletions

View file

@ -1,3 +1,6 @@
from time import time
async def m001_initial(db):
"""
Creates an improved withdraw table and migrates the existing data.
@ -132,3 +135,17 @@ async def m006_webhook_headers_and_body(db):
"ALTER TABLE withdraw.withdraw_link ADD COLUMN webhook_headers TEXT;"
)
await db.execute("ALTER TABLE withdraw.withdraw_link ADD COLUMN webhook_body TEXT;")
async def m007_add_created_at_timestamp(db):
await db.execute(
"ALTER TABLE withdraw.withdraw_link "
f"ADD COLUMN created_at TIMESTAMP DEFAULT {db.timestamp_column_default}"
)
# Set created_at to current time for all existing rows
await db.execute(
f"""
UPDATE withdraw.withdraw_link SET created_at = {db.timestamp_placeholder}
""",
(int(time()),),
)