Skip to content

Commit

Permalink
Fix #238: migration to backport prod index
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Oct 2, 2024
1 parent 01dc9eb commit 15d461c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions migrations/versions/20241001_8433b007b38a_index_backport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Create index on lowercase primary emails
Revision ID: 8433b007b38a
Revises: 3689b813fe22
Create Date: 2024-10-01 18:46:43.405004
"""
# pylint: disable=no-member invalid-name
# no-member is triggered by alembic.op, which has dynamically added functions
# invalid-name is triggered by migration file names with a date prefix
# invalid-name is triggered by top-level alembic constants like revision instead of REVISION

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "8433b007b38a" # pragma: allowlist secret
down_revision = "3689b813fe22" # pragma: allowlist secret
branch_labels = None
depends_on = None


def upgrade():
op.execute(
"""CREATE UNIQUE INDEX IF NOT EXISTS idx_email_primary_unique_email_lower ON public.emails USING btree (lower((primary_email)::text));"""
)


def downgrade():
op.execute("""DROP INDEX IF EXISTS idx_email_primary_unique_email_lower;""")

0 comments on commit 15d461c

Please sign in to comment.