From 6dd876163d485d5615cb7e98a89a46c77c233764 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 04 2018 09:01:03 +0000 Subject: Add an index on the ssh_search_key field in deploykeys Signed-off-by: Pierre-Yves Chibon --- diff --git a/alembic/versions/0a8f99c161e2_index_ssh_search_key.py b/alembic/versions/0a8f99c161e2_index_ssh_search_key.py new file mode 100644 index 0000000..948d677 --- /dev/null +++ b/alembic/versions/0a8f99c161e2_index_ssh_search_key.py @@ -0,0 +1,34 @@ +"""Add an index on ssh_search_key + +Revision ID: 0a8f99c161e2 +Revises: ba538b2648b7 +Create Date: 2018-10-04 10:49:44.739141 + +""" + +# revision identifiers, used by Alembic. +revision = '0a8f99c161e2' +down_revision = 'ba538b2648b7' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + """ Creates an index on ssh_search_key in the deploykeys table. + """ + op.create_index( + op.f("ix_deploykeys_deploykeys_ssh_search_key"), + "deploykeys", + ["ssh_search_key"], + unique=True, + ) + + +def downgrade(): + """ Drop index on ssh_search_key in the deploykeys table. + """ + op.drop_index( + op.f("ix_deploykeys_deploykeys_ssh_search_key"), + table_name="deploykeys" + )