From 1ac60d3c4902e42176e521336680ae28f1dab5f2 Mon Sep 17 00:00:00 2001 From: Philip Cheung Date: Mon, 7 Oct 2024 14:39:56 +0800 Subject: [PATCH] changed date --- .../versions/691c39dbac74_changed_date.py | 29 +++++++++++++++++++ backend/app/models.py | 4 +-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 backend/app/alembic/versions/691c39dbac74_changed_date.py diff --git a/backend/app/alembic/versions/691c39dbac74_changed_date.py b/backend/app/alembic/versions/691c39dbac74_changed_date.py new file mode 100644 index 0000000..8d199a1 --- /dev/null +++ b/backend/app/alembic/versions/691c39dbac74_changed_date.py @@ -0,0 +1,29 @@ +"""changed date + +Revision ID: 691c39dbac74 +Revises: 94afd163eba3 +Create Date: 2024-10-07 14:38:57.274294 + +""" +from alembic import op +import sqlalchemy as sa +import sqlmodel.sql.sqltypes + + +# revision identifiers, used by Alembic. +revision = '691c39dbac74' +down_revision = '94afd163eba3' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### diff --git a/backend/app/models.py b/backend/app/models.py index 1cb1740..e5c4f77 100644 --- a/backend/app/models.py +++ b/backend/app/models.py @@ -124,7 +124,7 @@ class MessageBase(SQLModel): class Message(MessageBase, table=True): id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True) - created_at: datetime = Field(default_factory=datetime.utcnow) + created_at: datetime = Field(default_factory=datetime.now) class MessageCreate(MessageBase): pass @@ -201,7 +201,7 @@ class CourseUpdate(CourseBase): class Course(CourseBase, table=True): id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True) - created_at: datetime = Field(default_factory=datetime.utcnow) + created_at: datetime = Field(default_factory=datetime.now) images: list["Image"] = Relationship(back_populates="course", cascade_delete=True) info_images: list["Info_Image"] = Relationship(back_populates="course", cascade_delete=True) schedule: list["Schedule"] = Relationship(back_populates="course", cascade_delete=True)