forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration: unique constraint for group-role-association
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...odel/migrations/alembic/versions_gxy/7cdc4eaff558_add_unique_constraint_to_group_role_.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,35 @@ | ||
"""Add unique constraint to group-role-association | ||
Revision ID: 7cdc4eaff558 | ||
Revises: ad1d893fa15f | ||
Create Date: 2024-08-29 15:18:05.790399 | ||
""" | ||
|
||
from galaxy.model.migrations.util import ( | ||
create_unique_constraint, | ||
drop_constraint, | ||
transaction, | ||
) | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "7cdc4eaff558" | ||
down_revision = "ad1d893fa15f" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
table_name = "group_role_association" | ||
constraint_column_names = ["group_id", "role_id"] | ||
unique_constraint_name = ( | ||
"group_role_association_group_id_key" # This is what the model's naming convention will generate. | ||
) | ||
|
||
|
||
def upgrade(): | ||
with transaction(): | ||
create_unique_constraint(unique_constraint_name, table_name, constraint_column_names) | ||
|
||
|
||
def downgrade(): | ||
with transaction(): | ||
drop_constraint(unique_constraint_name, table_name) |