diff --git a/backend/app/alembic/versions/e6b42c5752d5_changed_all_date_to_string.py b/backend/app/alembic/versions/e6b42c5752d5_changed_all_date_to_string.py new file mode 100644 index 0000000..a98b79f --- /dev/null +++ b/backend/app/alembic/versions/e6b42c5752d5_changed_all_date_to_string.py @@ -0,0 +1,43 @@ +"""changed all date to string + +Revision ID: e6b42c5752d5 +Revises: 691c39dbac74 +Create Date: 2024-10-07 14:52:05.314791 + +""" +from alembic import op +import sqlalchemy as sa +import sqlmodel.sql.sqltypes +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = 'e6b42c5752d5' +down_revision = '691c39dbac74' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('course', 'created_at', + existing_type=postgresql.TIMESTAMP(), + type_=sqlmodel.sql.sqltypes.AutoString(), + existing_nullable=False) + op.alter_column('message', 'created_at', + existing_type=postgresql.TIMESTAMP(), + type_=sqlmodel.sql.sqltypes.AutoString(), + existing_nullable=False) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('message', 'created_at', + existing_type=sqlmodel.sql.sqltypes.AutoString(), + type_=postgresql.TIMESTAMP(), + existing_nullable=False) + op.alter_column('course', 'created_at', + existing_type=sqlmodel.sql.sqltypes.AutoString(), + type_=postgresql.TIMESTAMP(), + existing_nullable=False) + # ### end Alembic commands ### diff --git a/backend/app/models.py b/backend/app/models.py index e5c4f77..d11bdfe 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.now) + created_at: str = 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.now) + created_at: str = 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) @@ -212,7 +212,7 @@ class CoursePublic(CourseBase): images: list["Image"] info_images: list["Info_Image"] schedule: list["Schedule"] - created_at: datetime + created_at: str class CoursesPublic(SQLModel): data: list[CoursePublic] @@ -254,7 +254,7 @@ class ScheduleBase(SQLModel): title: str = Field(max_length=255) info1: str = Field(max_length=255) info2: str = Field(max_length=255) - date: str = datetime + date: str class ScheduleUpdate(ScheduleBase): pass