fix: account insert
This commit is contained in:
+2
-3
@@ -1,5 +1,4 @@
|
|||||||
import json
|
import json
|
||||||
from datetime import datetime
|
|
||||||
from time import time
|
from time import time
|
||||||
from typing import Literal, Optional, Union
|
from typing import Literal, Optional, Union
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
@@ -40,14 +39,14 @@ async def create_account(
|
|||||||
conn: Optional[Connection] = None,
|
conn: Optional[Connection] = None,
|
||||||
) -> Account:
|
) -> Account:
|
||||||
if not account:
|
if not account:
|
||||||
now = datetime.now()
|
now = int(time())
|
||||||
account = Account(id=uuid4().hex, created_at=now, updated_at=now)
|
account = Account(id=uuid4().hex, created_at=now, updated_at=now)
|
||||||
await (conn or db).insert("accounts", account)
|
await (conn or db).insert("accounts", account)
|
||||||
return account
|
return account
|
||||||
|
|
||||||
|
|
||||||
async def update_account(account: Account) -> Account:
|
async def update_account(account: Account) -> Account:
|
||||||
account.updated_at = datetime.now()
|
account.updated_at = int(time())
|
||||||
await db.update("accounts", account)
|
await db.update("accounts", account)
|
||||||
return account
|
return account
|
||||||
|
|
||||||
|
|||||||
@@ -565,13 +565,3 @@ async def m023_add_column_column_to_apipayments(db):
|
|||||||
|
|
||||||
async def m024_drop_pending(db):
|
async def m024_drop_pending(db):
|
||||||
await db.execute("ALTER TABLE apipayments DROP COLUMN pending")
|
await db.execute("ALTER TABLE apipayments DROP COLUMN pending")
|
||||||
|
|
||||||
|
|
||||||
async def m025_add_pubkey_to_accounts(db):
|
|
||||||
"""
|
|
||||||
Adds pubkey column to accounts.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
await db.execute("ALTER TABLE accounts ADD COLUMN pubkey TEXT")
|
|
||||||
except OperationalError:
|
|
||||||
pass
|
|
||||||
|
|||||||
Reference in New Issue
Block a user