2024-03-22 17:11:18 +01:00
|
|
|
"""Add unique index to members
|
|
|
|
|
|
|
|
Revision ID: a000d800f45f
|
|
|
|
Revises: 17cc8cb77be5
|
|
|
|
Create Date: 2024-03-21 15:52:09.403257
|
|
|
|
|
|
|
|
"""
|
2024-03-23 01:39:08 +01:00
|
|
|
|
2024-03-22 17:11:18 +01:00
|
|
|
from typing import Sequence, Union
|
|
|
|
|
|
|
|
import sqlalchemy as sa
|
|
|
|
|
2024-03-23 01:39:08 +01:00
|
|
|
from alembic import op
|
2024-03-22 17:11:18 +01:00
|
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
|
|
revision: str = "a000d800f45f"
|
|
|
|
down_revision: Union[str, None] = "17cc8cb77be5"
|
|
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
|
|
|
|
|
|
def upgrade() -> None:
|
|
|
|
op.create_index(
|
|
|
|
"members_user_name_idx",
|
|
|
|
"members",
|
|
|
|
["user_id", sa.text("lower(name)")],
|
|
|
|
unique=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def downgrade() -> None:
|
|
|
|
op.drop_index("members_user_name_idx", table_name="members")
|