-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #238: migration to backport prod index
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
migrations/versions/20241001_8433b007b38a_index_backport.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;""") |