-
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.
Order of just "ordering" column is not meaningful. Ordering takes always place inside a parent feature which should always be included in th queries.
- Loading branch information
Showing
3 changed files
with
248 additions
and
8 deletions.
There are no files selected for viewing
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
206 changes: 206 additions & 0 deletions
206
database/migrations/versions/2024_12_02_1351-09f44e0e7110_ordering_index_fixes.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,206 @@ | ||
"""ordering index fixes | ||
Revision ID: 09f44e0e7110 | ||
Revises: 4e3c0868ea98 | ||
Create Date: 2024-12-02 13:51:55.645788 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
import geoalchemy2 | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "09f44e0e7110" | ||
down_revision: Union[str, None] = "4e3c0868ea98" | ||
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.drop_index( | ||
"ix_hame_land_use_area_ordering", | ||
table_name="land_use_area", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_land_use_area_plan_id_ordering", | ||
"land_use_area", | ||
["plan_id", "ordering"], | ||
unique=True, | ||
schema="hame", | ||
) | ||
op.drop_index( | ||
"ix_hame_land_use_point_ordering", | ||
table_name="land_use_point", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_land_use_point_plan_id_ordering", | ||
"land_use_point", | ||
["plan_id", "ordering"], | ||
unique=True, | ||
schema="hame", | ||
) | ||
op.drop_index("ix_hame_line_ordering", table_name="line", schema="hame") | ||
op.create_index( | ||
"ix_line_plan_id_ordering", | ||
"line", | ||
["plan_id", "ordering"], | ||
unique=True, | ||
schema="hame", | ||
) | ||
op.drop_index("ix_hame_other_area_ordering", table_name="other_area", schema="hame") | ||
op.create_index( | ||
"ix_other_area_plan_id_ordering", | ||
"other_area", | ||
["plan_id", "ordering"], | ||
unique=True, | ||
schema="hame", | ||
) | ||
op.drop_index( | ||
"ix_hame_other_point_ordering", table_name="other_point", schema="hame" | ||
) | ||
op.create_index( | ||
"ix_other_point_plan_id_ordering", | ||
"other_point", | ||
["plan_id", "ordering"], | ||
unique=True, | ||
schema="hame", | ||
) | ||
op.drop_index( | ||
"ix_hame_plan_proposition_ordering", | ||
table_name="plan_proposition", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_plan_proposition_plan_regulation_group_id_ordering", | ||
"plan_proposition", | ||
["plan_regulation_group_id", "ordering"], | ||
unique=False, | ||
schema="hame", | ||
) | ||
op.drop_index( | ||
"ix_hame_plan_regulation_ordering", | ||
table_name="plan_regulation", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_plan_regulation_plan_regulation_group_id_ordering", | ||
"plan_regulation", | ||
["plan_regulation_group_id", "ordering"], | ||
unique=True, | ||
schema="hame", | ||
) | ||
op.drop_index( | ||
"ix_hame_plan_regulation_group_ordering", | ||
table_name="plan_regulation_group", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_plan_regulation_group_plan_id_ordering", | ||
"plan_regulation_group", | ||
["plan_id", "ordering"], | ||
unique=False, | ||
schema="hame", | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index( | ||
"ix_plan_regulation_group_plan_id_ordering", | ||
table_name="plan_regulation_group", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_hame_plan_regulation_group_ordering", | ||
"plan_regulation_group", | ||
["ordering"], | ||
unique=False, | ||
schema="hame", | ||
) | ||
op.drop_index( | ||
"ix_plan_regulation_plan_regulation_group_id_ordering", | ||
table_name="plan_regulation", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_hame_plan_regulation_ordering", | ||
"plan_regulation", | ||
["ordering"], | ||
unique=False, | ||
schema="hame", | ||
) | ||
op.drop_index( | ||
"ix_plan_proposition_plan_regulation_group_id_ordering", | ||
table_name="plan_proposition", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_hame_plan_proposition_ordering", | ||
"plan_proposition", | ||
["ordering"], | ||
unique=False, | ||
schema="hame", | ||
) | ||
op.drop_index( | ||
"ix_other_point_plan_id_ordering", | ||
table_name="other_point", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_hame_other_point_ordering", | ||
"other_point", | ||
["ordering"], | ||
unique=False, | ||
schema="hame", | ||
) | ||
op.drop_index( | ||
"ix_other_area_plan_id_ordering", | ||
table_name="other_area", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_hame_other_area_ordering", | ||
"other_area", | ||
["ordering"], | ||
unique=False, | ||
schema="hame", | ||
) | ||
op.drop_index("ix_line_plan_id_ordering", table_name="line", schema="hame") | ||
op.create_index( | ||
"ix_hame_line_ordering", | ||
"line", | ||
["ordering"], | ||
unique=False, | ||
schema="hame", | ||
) | ||
op.drop_index( | ||
"ix_land_use_point_plan_id_ordering", | ||
table_name="land_use_point", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_hame_land_use_point_ordering", | ||
"land_use_point", | ||
["ordering"], | ||
unique=False, | ||
schema="hame", | ||
) | ||
op.drop_index( | ||
"ix_land_use_area_plan_id_ordering", | ||
table_name="land_use_area", | ||
schema="hame", | ||
) | ||
op.create_index( | ||
"ix_hame_land_use_area_ordering", | ||
"land_use_area", | ||
["ordering"], | ||
unique=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