Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init #63

Merged
merged 3 commits into from
Nov 30, 2024
Merged

init #63

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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