-
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.
Short names are unique only within the plan not globally.
- Loading branch information
Showing
2 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
database/migrations/versions/2024_12_02_1354-e9a045c08304_short_name_uniqueness_fix.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,66 @@ | ||
"""short name uniqueness fix | ||
Revision ID: e9a045c08304 | ||
Revises: 09f44e0e7110 | ||
Create Date: 2024-12-02 13:54:23.903091 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
import geoalchemy2 | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "e9a045c08304" | ||
down_revision: Union[str, None] = "09f44e0e7110" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.alter_column( | ||
"plan_regulation_group", | ||
"short_name", | ||
existing_type=sa.VARCHAR(), | ||
nullable=True, | ||
schema="hame", | ||
) | ||
op.drop_index( | ||
"ix_hame_plan_regulation_group_short_name", | ||
table_name="plan_regulation_group", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_plan_regulation_group_plan_id_short_name", | ||
"plan_regulation_group", | ||
["plan_id", "short_name"], | ||
unique=True, | ||
schema="hame", | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index( | ||
"ix_plan_regulation_group_plan_id_short_name", | ||
table_name="plan_regulation_group", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_hame_plan_regulation_group_short_name", | ||
"plan_regulation_group", | ||
["short_name"], | ||
unique=True, | ||
schema="hame", | ||
) | ||
op.alter_column( | ||
"plan_regulation_group", | ||
"short_name", | ||
existing_type=sa.VARCHAR(), | ||
nullable=False, | ||
schema="hame", | ||
) | ||
# ### end Alembic commands ### |
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