0a8f99c161e2_index_ssh_search_key.py 959 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """Add an index on ssh_search_key
  2. Revision ID: 0a8f99c161e2
  3. Revises: ba538b2648b7
  4. Create Date: 2018-10-04 10:49:44.739141
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = "0a8f99c161e2"
  8. down_revision = "ba538b2648b7"
  9. from alembic import op
  10. import sqlalchemy as sa
  11. def upgrade():
  12. """ Creates an index on ssh_search_key in the deploykeys table.
  13. """
  14. op.alter_column(
  15. "deploykeys",
  16. "ssh_search_key",
  17. nullable=False,
  18. type_=sa.String(length=60),
  19. )
  20. op.create_index(
  21. op.f("ix_deploykeys_deploykeys_ssh_search_key"),
  22. "deploykeys",
  23. ["ssh_search_key"],
  24. unique=True,
  25. )
  26. def downgrade():
  27. """ Drop index on ssh_search_key in the deploykeys table.
  28. """
  29. op.drop_index(
  30. op.f("ix_deploykeys_deploykeys_ssh_search_key"),
  31. table_name="deploykeys",
  32. )
  33. op.alter_column(
  34. "deploykeys", "ssh_search_key", nullable=False, type_=sa.Text
  35. )