Skip to content

Commit

Permalink
Merge pull request #63 from profcomff/nullable
Browse files Browse the repository at this point in the history
init
  • Loading branch information
parfenovma authored Nov 30, 2024
2 parents a82a2bb + 2b18e96 commit 626545f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ format:
autoflake -r --in-place --remove-all-unused-imports ./rating_api
isort ./rating_api
black ./rating_api

autoflake -r --in-place --remove-all-unused-imports ./migrations
isort ./migrations
black ./migrations

db:
docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-rating_api postgres:15

Expand Down
24 changes: 24 additions & 0 deletions migrations/versions/20181e0d6aab_make_nullable_timetable_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""make nullable timetable_id
Revision ID: 20181e0d6aab
Revises: edcc1a448ffb
Create Date: 2024-11-30 18:45:08.527638
"""

from alembic import op


# revision identifiers, used by Alembic.
revision = '20181e0d6aab'
down_revision = 'edcc1a448ffb'
branch_labels = None
depends_on = None


def upgrade():
op.drop_constraint('lecturer_timetable_id_key', 'lecturer', type_='unique')


def downgrade():
op.create_unique_constraint('lecturer_timetable_id_key', 'lecturer', ['timetable_id'])
2 changes: 1 addition & 1 deletion rating_api/models/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Lecturer(BaseDbModel):
last_name: Mapped[str] = mapped_column(String, nullable=False)
middle_name: Mapped[str] = mapped_column(String, nullable=False)
avatar_link: Mapped[str] = mapped_column(String, nullable=True)
timetable_id: Mapped[int] = mapped_column(Integer, unique=True, nullable=False)
timetable_id: Mapped[int]
comments: Mapped[list[Comment]] = relationship("Comment", back_populates="lecturer")
is_deleted: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)

Expand Down
2 changes: 1 addition & 1 deletion rating_api/schemas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class LecturerPost(Base):
last_name: str
middle_name: str
avatar_link: str | None = None
timetable_id: int
timetable_id: int | None = None


class LecturerPatch(Base):
Expand Down

0 comments on commit 626545f

Please sign in to comment.