diff --git a/lemur/migrations/versions/8323a5ea723a_.py b/lemur/migrations/versions/8323a5ea723a_.py new file mode 100644 index 00000000..9505cdb1 --- /dev/null +++ b/lemur/migrations/versions/8323a5ea723a_.py @@ -0,0 +1,50 @@ +"""Add lowercase index for certificate name and cn and also for domain name + +Revision ID: 8323a5ea723a +Revises: b33c838cb669 +Create Date: 2020-01-10 10:51:44.776052 + +""" + +# revision identifiers, used by Alembic. +revision = '8323a5ea723a' +down_revision = 'b33c838cb669' + +from alembic import op +from sqlalchemy import text + +import sqlalchemy as sa + + +def upgrade(): + op.create_index( + "ix_certificates_cn_lower", + "certificates", + [text("lower(cn)")], + unique=False, + postgresql_ops={"lower(cn)": "gin_trgm_ops"}, + postgresql_using="gin", + ) + op.create_index( + "ix_certificates_name_lower", + "certificates", + [text("lower(name)")], + unique=False, + postgresql_ops={"lower(name)": "gin_trgm_ops"}, + postgresql_using="gin", + ) + op.create_index( + "ix_domains_name_lower", + "domains", + [text("lower(name)")], + unique=False, + postgresql_ops={"lower(name)": "gin_trgm_ops"}, + postgresql_using="gin", + ) + + + +def downgrade(): + op.drop_index("ix_certificates_cn_lower", table_name="certificates") + op.drop_index("ix_certificates_name_lower", table_name="certificates") + op.drop_index("ix_domains_name_lower", table_name="domains") diff --git a/lemur/migrations/versions/ee827d1e1974_.py b/lemur/migrations/versions/ee827d1e1974_.py index 56696fe3..649f1ed7 100644 --- a/lemur/migrations/versions/ee827d1e1974_.py +++ b/lemur/migrations/versions/ee827d1e1974_.py @@ -45,6 +45,6 @@ def upgrade(): def downgrade(): - op.drop_index("ix_domains_name", table_name="domains") + op.drop_index("ix_domains_name_gin", table_name="domains") op.drop_index("ix_certificates_name", table_name="certificates") op.drop_index("ix_certificates_cn", table_name="certificates")