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

Fix: Add unique key constraint to resume_submission table #52

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions wacruit/src/apps/resume/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from sqlalchemy import DateTime
from sqlalchemy import ForeignKey
from sqlalchemy import Text
from sqlalchemy import UniqueConstraint
from sqlalchemy.orm import Mapped
from sqlalchemy.orm import mapped_column
from sqlalchemy.orm import relationship
Expand Down Expand Up @@ -54,6 +55,7 @@ def __str__(self):

class ResumeSubmission(DeclarativeBase):
__tablename__ = "resume_submission"
__table_args__ = (UniqueConstraint("user_id", "question_id", "recruiting_id"),)

id: Mapped[intpk]
user_id: Mapped[int | None] = mapped_column(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Add unique key constraint to resume_submission table

Revision ID: 9dda918f3fba
Revises: 5bbc8b8ae19c
Create Date: 2023-08-10 00:25:36.865535

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "9dda918f3fba"
down_revision = "5bbc8b8ae19c"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_unique_constraint(
"ak_user_question",
"resume_submission",
["user_id", "question_id", "recruiting_id"],
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint("ak_user_question", "resume_submission", type_="unique")
# ### end Alembic commands ###