diff --git a/migrations/versions/7388a2c219d2_add_user_id_to_lecturer_user.py b/migrations/versions/7388a2c219d2_add_user_id_to_lecturer_user.py new file mode 100644 index 0000000..1194342 --- /dev/null +++ b/migrations/versions/7388a2c219d2_add_user_id_to_lecturer_user.py @@ -0,0 +1,24 @@ +"""add-user-id-to-lecturer-user + +Revision ID: 7388a2c219d2 +Revises: fee34ac4fcab +Create Date: 2024-11-10 04:07:42.997861 + +""" + +import sqlalchemy as sa +from alembic import op + + +revision = '7388a2c219d2' +down_revision = 'fee34ac4fcab' +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column('lecturer_user_comment', sa.Column('user_id', sa.Integer(), nullable=False)) + + +def downgrade(): + op.drop_column('lecturer_user_comment', 'user_id') diff --git a/migrations/versions/fee34ac4fcab_delete_user_id_from_lectureruser.py b/migrations/versions/fee34ac4fcab_delete_user_id_from_lectureruser.py index 07960ec..5619568 100644 --- a/migrations/versions/fee34ac4fcab_delete_user_id_from_lectureruser.py +++ b/migrations/versions/fee34ac4fcab_delete_user_id_from_lectureruser.py @@ -6,8 +6,8 @@ """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = 'fee34ac4fcab' diff --git a/rating_api/models/db.py b/rating_api/models/db.py index ad74619..371a6b9 100644 --- a/rating_api/models/db.py +++ b/rating_api/models/db.py @@ -63,6 +63,7 @@ class Comment(BaseDbModel): class LecturerUserComment(BaseDbModel): id: Mapped[int] = mapped_column(Integer, primary_key=True) + user_id: Mapped[int] = mapped_column(Integer, nullable=False) lecturer_id: Mapped[int] = mapped_column(Integer, ForeignKey("lecturer.id")) create_ts: Mapped[datetime.datetime] = mapped_column(DateTime, default=datetime.datetime.utcnow, nullable=False) update_ts: Mapped[datetime.datetime] = mapped_column(DateTime, default=datetime.datetime.utcnow, nullable=False) diff --git a/rating_api/schemas/models.py b/rating_api/schemas/models.py index de510a8..3a6f1b0 100644 --- a/rating_api/schemas/models.py +++ b/rating_api/schemas/models.py @@ -20,6 +20,7 @@ class CommentGet(Base): lecturer_id: int + class CommentPost(Base): subject: str text: str