Blame alembic/versions/0a8f99c161e2_index_ssh_search_key.py
|
Pierre-Yves Chibon |
6dd876 |
"""Add an index on ssh_search_key
|
|
Pierre-Yves Chibon |
6dd876 |
|
|
Pierre-Yves Chibon |
6dd876 |
Revision ID: 0a8f99c161e2
|
|
Pierre-Yves Chibon |
6dd876 |
Revises: ba538b2648b7
|
|
Pierre-Yves Chibon |
6dd876 |
Create Date: 2018-10-04 10:49:44.739141
|
|
Pierre-Yves Chibon |
6dd876 |
|
|
Pierre-Yves Chibon |
6dd876 |
"""
|
|
Pierre-Yves Chibon |
6dd876 |
|
|
Pierre-Yves Chibon |
6dd876 |
# revision identifiers, used by Alembic.
|
|
Patrick Uiterwijk |
702cfe |
revision = "0a8f99c161e2"
|
|
Patrick Uiterwijk |
702cfe |
down_revision = "ba538b2648b7"
|
|
Pierre-Yves Chibon |
6dd876 |
|
|
Pierre-Yves Chibon |
6dd876 |
from alembic import op
|
|
Pierre-Yves Chibon |
6dd876 |
import sqlalchemy as sa
|
|
Pierre-Yves Chibon |
6dd876 |
|
|
Pierre-Yves Chibon |
6dd876 |
|
|
Pierre-Yves Chibon |
6dd876 |
def upgrade():
|
|
Pierre-Yves Chibon |
6dd876 |
""" Creates an index on ssh_search_key in the deploykeys table.
|
|
Pierre-Yves Chibon |
6dd876 |
"""
|
|
Patrick Uiterwijk |
702cfe |
op.alter_column(
|
|
Patrick Uiterwijk |
702cfe |
"deploykeys",
|
|
Patrick Uiterwijk |
702cfe |
"ssh_search_key",
|
|
Patrick Uiterwijk |
702cfe |
nullable=False,
|
|
Patrick Uiterwijk |
702cfe |
type_=sa.String(length=60),
|
|
Patrick Uiterwijk |
702cfe |
)
|
|
Pierre-Yves Chibon |
6dd876 |
op.create_index(
|
|
Pierre-Yves Chibon |
6dd876 |
op.f("ix_deploykeys_deploykeys_ssh_search_key"),
|
|
Pierre-Yves Chibon |
6dd876 |
"deploykeys",
|
|
Pierre-Yves Chibon |
6dd876 |
["ssh_search_key"],
|
|
Pierre-Yves Chibon |
6dd876 |
unique=True,
|
|
Pierre-Yves Chibon |
6dd876 |
)
|
|
Pierre-Yves Chibon |
6dd876 |
|
|
Pierre-Yves Chibon |
6dd876 |
|
|
Pierre-Yves Chibon |
6dd876 |
def downgrade():
|
|
Pierre-Yves Chibon |
6dd876 |
""" Drop index on ssh_search_key in the deploykeys table.
|
|
Pierre-Yves Chibon |
6dd876 |
"""
|
|
Pierre-Yves Chibon |
6dd876 |
op.drop_index(
|
|
Pierre-Yves Chibon |
6dd876 |
op.f("ix_deploykeys_deploykeys_ssh_search_key"),
|
|
Patrick Uiterwijk |
702cfe |
table_name="deploykeys",
|
|
Patrick Uiterwijk |
702cfe |
)
|
|
Patrick Uiterwijk |
702cfe |
op.alter_column(
|
|
Patrick Uiterwijk |
702cfe |
"deploykeys", "ssh_search_key", nullable=False, type_=sa.Text
|
|
Pierre-Yves Chibon |
6dd876 |
)
|