-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CERNAccess: Ensure unique reservation codes (#178)
- Loading branch information
Showing
5 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...access/migrations/20241015_1702_92377810f14e_make_reservation_code_unique_and_nullable.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,27 @@ | ||
"""Make reservation code unique and nullable | ||
Revision ID: 92377810f14e | ||
Revises: ee88b64f9494 | ||
Create Date: 2024-10-15 17:02:59.886902 | ||
""" | ||
|
||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '92377810f14e' | ||
down_revision = 'ee88b64f9494' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.alter_column('access_requests', 'reservation_code', nullable=True, schema='plugin_cern_access') | ||
op.execute("UPDATE plugin_cern_access.access_requests SET reservation_code = NULL WHERE reservation_code = ''") | ||
op.create_unique_constraint(None, 'access_requests', ['reservation_code'], schema='plugin_cern_access') | ||
|
||
|
||
def downgrade(): | ||
op.drop_constraint('uq_access_requests_reservation_code', 'access_requests', schema='plugin_cern_access') | ||
op.execute("UPDATE plugin_cern_access.access_requests SET reservation_code = '' WHERE reservation_code IS NULL") | ||
op.alter_column('access_requests', 'reservation_code', nullable=False, schema='plugin_cern_access') |
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