diff --git a/crud.py b/crud.py index b08f0ea..a70c81e 100644 --- a/crud.py +++ b/crud.py @@ -80,6 +80,7 @@ async def create_appointment( end_time=data.end_time, schedule=schedule_id, paid=False, + created_at=datetime.now(), ) await db.execute( insert_query("lncalendar.appointment", appointment), @@ -150,6 +151,7 @@ async def create_unavailable_time(data: CreateUnavailableTime) -> UnavailableTim start_time=data.start_time, end_time=data.end_time or data.start_time, schedule=data.schedule, + created_at=datetime.now(), ) await db.execute( insert_query("lncalendar.unavailable", unavailable_time), diff --git a/migrations.py b/migrations.py index ff16927..27e3f9a 100644 --- a/migrations.py +++ b/migrations.py @@ -51,3 +51,21 @@ async def m001_initial(db): ); """ ) + + +async def m002_rename_time_to_created_at(db): + """ + Rename time to created_at in the unavailability table. + """ + await db.execute( + """ + ALTER TABLE lncalendar.unavailable + RENAME COLUMN time TO created_at; + """ + ) + await db.execute( + """ + ALTER TABLE lncalendar.appointment + RENAME COLUMN time TO created_at; + """ + ) diff --git a/models.py b/models.py index a6b7ed9..3ac1d84 100644 --- a/models.py +++ b/models.py @@ -1,3 +1,4 @@ +from datetime import datetime from typing import Optional from fastapi import Query @@ -49,6 +50,7 @@ class UnavailableTime(BaseModel): start_time: str end_time: str schedule: str + created_at: datetime class Appointment(BaseModel): @@ -60,4 +62,4 @@ class Appointment(BaseModel): end_time: str schedule: str paid: bool - time: int + created_at: datetime diff --git a/views_api.py b/views_api.py index 1f50e1e..f5b7d75 100644 --- a/views_api.py +++ b/views_api.py @@ -1,9 +1,7 @@ -import sched from http import HTTPStatus from fastapi import APIRouter, Depends, Query from fastapi.exceptions import HTTPException - from lnbits.core.crud import get_standalone_payment, get_user from lnbits.core.models import User, WalletTypeInfo from lnbits.core.services import create_invoice