fix: add compose indexes to version tables, per upstream changes
as of SQLAlchemy-Continuum v1.6.0 https://github.com/sqlalchemy-continuum/sqlalchemy-continuum/releases/tag/1.6.0 but these changes should be safe to add for older sqlalchemy-continuum as well
This commit is contained in:
parent
e7d6a10751
commit
665a9684af
1 changed files with 106 additions and 0 deletions
|
|
@ -0,0 +1,106 @@
|
||||||
|
"""add composite indexes per upstream changes
|
||||||
|
|
||||||
|
Revision ID: f51330d1fa4d
|
||||||
|
Revises: 46fb4711411d
|
||||||
|
Create Date: 2026-02-01 18:24:25.713961
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
import wuttjamaican.db.util
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "f51330d1fa4d"
|
||||||
|
down_revision: Union[str, None] = "46fb4711411d"
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
|
||||||
|
# *_version
|
||||||
|
op.create_index(
|
||||||
|
"ix_permission_version_pk_transaction_id",
|
||||||
|
"permission_version",
|
||||||
|
["role_uuid", "permission", sa.literal_column("transaction_id DESC")],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
"ix_permission_version_pk_validity",
|
||||||
|
"permission_version",
|
||||||
|
["role_uuid", "permission", "transaction_id", "end_transaction_id"],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
"ix_person_version_pk_transaction_id",
|
||||||
|
"person_version",
|
||||||
|
["uuid", sa.literal_column("transaction_id DESC")],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
"ix_person_version_pk_validity",
|
||||||
|
"person_version",
|
||||||
|
["uuid", "transaction_id", "end_transaction_id"],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
"ix_role_version_pk_transaction_id",
|
||||||
|
"role_version",
|
||||||
|
["uuid", sa.literal_column("transaction_id DESC")],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
"ix_role_version_pk_validity",
|
||||||
|
"role_version",
|
||||||
|
["uuid", "transaction_id", "end_transaction_id"],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
"ix_user_version_pk_transaction_id",
|
||||||
|
"user_version",
|
||||||
|
["uuid", sa.literal_column("transaction_id DESC")],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
"ix_user_version_pk_validity",
|
||||||
|
"user_version",
|
||||||
|
["uuid", "transaction_id", "end_transaction_id"],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
"ix_user_x_role_version_pk_transaction_id",
|
||||||
|
"user_x_role_version",
|
||||||
|
["uuid", sa.literal_column("transaction_id DESC")],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
"ix_user_x_role_version_pk_validity",
|
||||||
|
"user_x_role_version",
|
||||||
|
["uuid", "transaction_id", "end_transaction_id"],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
|
||||||
|
# *_version
|
||||||
|
op.drop_index(
|
||||||
|
"ix_user_x_role_version_pk_validity", table_name="user_x_role_version"
|
||||||
|
)
|
||||||
|
op.drop_index(
|
||||||
|
"ix_user_x_role_version_pk_transaction_id", table_name="user_x_role_version"
|
||||||
|
)
|
||||||
|
op.drop_index("ix_user_version_pk_validity", table_name="user_version")
|
||||||
|
op.drop_index("ix_user_version_pk_transaction_id", table_name="user_version")
|
||||||
|
op.drop_index("ix_role_version_pk_validity", table_name="role_version")
|
||||||
|
op.drop_index("ix_role_version_pk_transaction_id", table_name="role_version")
|
||||||
|
op.drop_index("ix_person_version_pk_validity", table_name="person_version")
|
||||||
|
op.drop_index("ix_person_version_pk_transaction_id", table_name="person_version")
|
||||||
|
op.drop_index("ix_permission_version_pk_validity", table_name="permission_version")
|
||||||
|
op.drop_index(
|
||||||
|
"ix_permission_version_pk_transaction_id", table_name="permission_version"
|
||||||
|
)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue