32 lines
698 B
Python
32 lines
698 B
Python
|
"""Add unique index to members
|
||
|
|
||
|
Revision ID: a000d800f45f
|
||
|
Revises: 17cc8cb77be5
|
||
|
Create Date: 2024-03-21 15:52:09.403257
|
||
|
|
||
|
"""
|
||
|
from typing import Sequence, Union
|
||
|
|
||
|
from alembic import op
|
||
|
import sqlalchemy as sa
|
||
|
|
||
|
|
||
|
# 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")
|