diff --git a/data/migrations/versions/a3ba52d02dec_initial_keyserver.py b/data/migrations/versions/a3ba52d02dec_initial_keyserver.py index 30ec23aba..360d427e3 100644 --- a/data/migrations/versions/a3ba52d02dec_initial_keyserver.py +++ b/data/migrations/versions/a3ba52d02dec_initial_keyserver.py @@ -12,7 +12,6 @@ down_revision = 'e4129c93e477' from alembic import op import sqlalchemy as sa -from sqlalchemy.dialects import mysql from util.migrate import UTF8LongText @@ -32,6 +31,16 @@ def upgrade(tables): [{'name':'service_key_submitted'}], ) + op.bulk_insert(tables.logentrykind, + [ + {'name':'service_key_create'}, + {'name':'service_key_approve'}, + {'name':'service_key_delete'}, + {'name':'service_key_modify'}, + {'name':'service_key_extend'}, + {'name':'service_key_rotate'}, + ]) + op.create_index('servicekeyapproval_approval_type', 'servicekeyapproval', ['approval_type'], unique=False) op.create_index('servicekeyapproval_approver_id', 'servicekeyapproval', ['approver_id'], unique=False) op.create_table( @@ -56,8 +65,44 @@ def upgrade(tables): op.add_column(u'notification', sa.Column('lookup_path', sa.String(length=255), nullable=True)) op.create_index('notification_lookup_path', 'notification', ['lookup_path'], unique=False) + op.drop_constraint(u'fk_logentry_account_id_user', 'logentry', type_='foreignkey') + op.alter_column('logentry', 'account_id', existing_type=sa.Integer(), nullable=True) + def downgrade(tables): + op.execute( + (tables.logentrykind.delete() + .where(tables.logentrykind.c.name == op.inline_literal('service_key_create'))) + ) + + op.execute( + (tables.logentrykind.delete() + .where(tables.logentrykind.c.name == op.inline_literal('service_key_approve'))) + ) + + op.execute( + (tables.logentrykind.delete() + .where(tables.logentrykind.c.name == op.inline_literal('service_key_delete'))) + ) + + op.execute( + (tables.logentrykind.delete() + .where(tables.logentrykind.c.name == op.inline_literal('service_key_modify'))) + ) + + op.execute( + (tables.logentrykind.delete() + .where(tables.logentrykind.c.name == op.inline_literal('service_key_extend'))) + ) + + op.execute( + (tables.logentrykind.delete() + .where(tables.logentrykind.c.name == op.inline_literal('service_key_rotate'))) + ) + op.drop_column(u'notification', 'lookup_path') op.drop_table('servicekey') op.drop_table('servicekeyapproval') + + op.alter_column('logentry', 'account_id', existing_type=sa.Integer(), nullable=False) + op.create_foreign_key(u'fk_logentry_account_id_user', 'logentry', 'user', ['account_id'], ['id'])