96 lines
3.9 KiB
Python
96 lines
3.9 KiB
Python
"""Update indexes
|
|
|
|
Revision ID: 11c969913a7e
|
|
Revises: 4f837664b686
|
|
Create Date: 2025-10-11 15:40:44.325096
|
|
|
|
"""
|
|
|
|
import sqlalchemy as sa
|
|
import sqlmodel.sql.sqltypes
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "11c969913a7e"
|
|
down_revision = "4f837664b686"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table("category", schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f("ix_category_user"), ["user"], unique=False)
|
|
|
|
with op.batch_alter_table("image", schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f("ix_image_user"), ["user"], unique=False)
|
|
|
|
with op.batch_alter_table("place", schema=None) as batch_op:
|
|
batch_op.create_index("idx_place_user_category", ["user", "category_id"], unique=False)
|
|
batch_op.create_index(batch_op.f("ix_place_category_id"), ["category_id"], unique=False)
|
|
batch_op.create_index(batch_op.f("ix_place_user"), ["user"], unique=False)
|
|
|
|
with op.batch_alter_table("trip", schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f("ix_trip_user"), ["user"], unique=False)
|
|
|
|
with op.batch_alter_table("tripchecklistitem", schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f("ix_tripchecklistitem_trip_id"), ["trip_id"], unique=False)
|
|
|
|
with op.batch_alter_table("tripday", schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f("ix_tripday_trip_id"), ["trip_id"], unique=False)
|
|
|
|
with op.batch_alter_table("tripitem", schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f("ix_tripitem_day_id"), ["day_id"], unique=False)
|
|
|
|
with op.batch_alter_table("tripmember", schema=None) as batch_op:
|
|
batch_op.create_index(
|
|
"idx_tripmember_trip_user_joined", ["trip_id", "user", "joined_at"], unique=False
|
|
)
|
|
batch_op.create_index(batch_op.f("ix_tripmember_trip_id"), ["trip_id"], unique=False)
|
|
|
|
with op.batch_alter_table("trippackinglistitem", schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f("ix_trippackinglistitem_trip_id"), ["trip_id"], unique=False)
|
|
|
|
with op.batch_alter_table("tripplacelink", schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f("ix_tripplacelink_place_id"), ["place_id"], unique=False)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table("tripplacelink", schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f("ix_tripplacelink_place_id"))
|
|
|
|
with op.batch_alter_table("trippackinglistitem", schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f("ix_trippackinglistitem_trip_id"))
|
|
|
|
with op.batch_alter_table("tripmember", schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f("ix_tripmember_trip_id"))
|
|
batch_op.drop_index("idx_tripmember_trip_user_joined")
|
|
|
|
with op.batch_alter_table("tripitem", schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f("ix_tripitem_day_id"))
|
|
|
|
with op.batch_alter_table("tripday", schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f("ix_tripday_trip_id"))
|
|
|
|
with op.batch_alter_table("tripchecklistitem", schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f("ix_tripchecklistitem_trip_id"))
|
|
|
|
with op.batch_alter_table("trip", schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f("ix_trip_user"))
|
|
|
|
with op.batch_alter_table("place", schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f("ix_place_user"))
|
|
batch_op.drop_index(batch_op.f("ix_place_category_id"))
|
|
batch_op.drop_index("idx_place_user_category")
|
|
|
|
with op.batch_alter_table("image", schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f("ix_image_user"))
|
|
|
|
with op.batch_alter_table("category", schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f("ix_category_user"))
|
|
|
|
# ### end Alembic commands ###
|