diff --git a/src/backend/app/db/db_models.py b/src/backend/app/db/db_models.py index 8c1ee1cd..4f44d9c3 100644 --- a/src/backend/app/db/db_models.py +++ b/src/backend/app/db/db_models.py @@ -83,9 +83,9 @@ class DbProject(Base): short_description = cast(str, Column(String)) description = cast(str, Column(String)) per_task_instructions = cast(str, Column(String)) - created = cast(datetime, Column(DateTime, default=timestamp, nullable=False)) + created_at = cast(datetime, Column(DateTime, default=timestamp, nullable=False)) last_updated = cast(datetime, Column(DateTime, default=timestamp)) - deadline = cast(datetime, Column(DateTime, default=timestamp)) + deadline_at = cast(datetime, Column(DateTime, default=timestamp)) # GEOMETRY outline = cast(WKBElement, Column(Geometry("POLYGON", srid=4326))) centroid = cast(WKBElement, Column(Geometry("POINT", srid=4326))) diff --git a/src/backend/app/migrations/versions/832089d4a1de_deadline_for_projects.py b/src/backend/app/migrations/versions/832089d4a1de_deadline_for_projects.py deleted file mode 100644 index 7f9f1eb6..00000000 --- a/src/backend/app/migrations/versions/832089d4a1de_deadline_for_projects.py +++ /dev/null @@ -1,29 +0,0 @@ -"""deadline for projects - -Revision ID: 832089d4a1de -Revises: 88ae62ec8876 -Create Date: 2024-07-13 05:01:32.713490 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision: str = "832089d4a1de" -down_revision: Union[str, None] = "88ae62ec8876" -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.add_column("projects", sa.Column("deadline", sa.DateTime(), nullable=True)) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column("projects", "deadline") - # ### end Alembic commands ### diff --git a/src/backend/app/migrations/versions/acee47666167_refine_field_name.py b/src/backend/app/migrations/versions/acee47666167_refine_field_name.py new file mode 100755 index 00000000..77034520 --- /dev/null +++ b/src/backend/app/migrations/versions/acee47666167_refine_field_name.py @@ -0,0 +1,34 @@ +"""refine field name + +Revision ID: acee47666167 +Revises: 88ae62ec8876 +Create Date: 2024-07-13 10:51:33.020864 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision: str = 'acee47666167' +down_revision: Union[str, None] = '88ae62ec8876' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('projects', sa.Column('created_at', sa.DateTime(), nullable=False)) + op.add_column('projects', sa.Column('deadline_at', sa.DateTime(), nullable=True)) + op.drop_column('projects', 'created') + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + #op.add_column('projects', sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=False)) + op.drop_column('projects', 'deadline_at') + op.drop_column('projects', 'created_at') + # ### end Alembic commands ### diff --git a/src/backend/app/projects/project_crud.py b/src/backend/app/projects/project_crud.py index 2167308a..ac393b3c 100644 --- a/src/backend/app/projects/project_crud.py +++ b/src/backend/app/projects/project_crud.py @@ -19,7 +19,7 @@ async def create_project_with_project_info( _id = uuid.uuid4() query = """ INSERT INTO projects ( - id, author_id, name, short_description, description, per_task_instructions, status, visibility, outline, no_fly_zones, dem_url, output_orthophoto_url, output_pointcloud_url, output_raw_url, task_split_dimension, deadline, created) + id, author_id, name, short_description, description, per_task_instructions, status, visibility, outline, no_fly_zones, dem_url, output_orthophoto_url, output_pointcloud_url, output_raw_url, task_split_dimension, deadline_at, created_at) VALUES ( :id, :author_id, @@ -36,7 +36,7 @@ async def create_project_with_project_info( :output_pointcloud_url, :output_raw_url, :task_split_dimension, - :deadline, + :deadline_at, CURRENT_TIMESTAMP ) RETURNING id @@ -60,7 +60,7 @@ async def create_project_with_project_info( "output_pointcloud_url": project_metadata.output_pointcloud_url, "output_raw_url": project_metadata.output_raw_url, "task_split_dimension": project_metadata.task_split_dimension, - "deadline": project_metadata.deadline, + "deadline_at": project_metadata.deadline_at, }, ) return project_id diff --git a/src/backend/app/projects/project_schemas.py b/src/backend/app/projects/project_schemas.py index 57ea986e..5e9a32cc 100644 --- a/src/backend/app/projects/project_schemas.py +++ b/src/backend/app/projects/project_schemas.py @@ -44,7 +44,7 @@ class ProjectIn(BaseModel): output_orthophoto_url: Optional[str] = None output_pointcloud_url: Optional[str] = None output_raw_url: Optional[str] = None - deadline: Optional[date] = None + deadline_at: Optional[date] = None @computed_field @property