-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unique constraint to document type
- Loading branch information
Showing
5 changed files
with
61 additions
and
17 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
papermerge/core/alembic/versions/85fda75f19f1_make_document_type_name_unique_for_user_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""make document type name unique for user_id | ||
Revision ID: 85fda75f19f1 | ||
Revises: bc29f69daca4 | ||
Create Date: 2024-11-25 10:03:03.516065 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "85fda75f19f1" | ||
down_revision: Union[str, None] = "bc29f69daca4" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
with op.batch_alter_table("document_types") as batch_op: | ||
batch_op.create_unique_constraint( | ||
"unique document type per user", | ||
columns=["name", "user_id"], | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
with op.batch_alter_table("document_types") as batch_op: | ||
batch_op.drop_constraint("unique document type per user") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters