8a3b10926153_create_deploy_keys_table.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. """Create deploy keys table
  2. Revision ID: 8a3b10926153
  3. Revises: 38581a8fbae2
  4. Create Date: 2017-02-09 12:45:59.553111
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = '8a3b10926153'
  8. down_revision = '38581a8fbae2'
  9. from alembic import op
  10. import sqlalchemy as sa
  11. def upgrade():
  12. op.create_table('deploykeys',
  13. sa.Column('id', sa.Integer(), nullable=False),
  14. sa.Column('project_id', sa.Integer(), nullable=True),
  15. sa.Column('pushaccess', sa.Boolean(), nullable=False),
  16. sa.Column('public_ssh_key', sa.Text(), nullable=False),
  17. sa.Column('ssh_short_key', sa.Text(), nullable=False),
  18. sa.Column('ssh_search_key', sa.Text(), nullable=False),
  19. sa.Column('creator_user_id', sa.Integer(), nullable=False),
  20. sa.Column('date_created', sa.DateTime(), nullable=False),
  21. sa.ForeignKeyConstraint(['creator_user_id'], ['users.id'], name=op.f('deploykeys_creator_user_id_fkey'), onupdate='CASCADE'),
  22. sa.ForeignKeyConstraint(['project_id'], ['projects.id'], name=op.f('deploykeys_project_id_fkey'), onupdate='CASCADE', ondelete='CASCADE'),
  23. sa.PrimaryKeyConstraint('id', name=op.f('deploykeys_pkey'))
  24. )
  25. op.create_index(op.f('ix_deploykeys_deploykeys_creator_user_id'), 'deploykeys', ['creator_user_id'], unique=False)
  26. def downgrade():
  27. op.drop_index(op.f('ix_deploykeys_deploykeys_creator_user_id'), table_name='deploykeys')
  28. op.drop_table('deploykeys')