This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/data/migrations/versions/a3ba52d02dec_initial_keyserver.py
2016-04-29 13:38:25 -04:00

63 lines
2.4 KiB
Python

"""initial keyserver
Revision ID: a3ba52d02dec
Revises: e4129c93e477
Create Date: 2016-03-30 15:28:32.036753
"""
# revision identifiers, used by Alembic.
revision = 'a3ba52d02dec'
down_revision = 'e4129c93e477'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
from util.migrate import UTF8LongText
def upgrade(tables):
op.create_table(
'servicekeyapproval',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('approver_id', sa.Integer(), nullable=True),
sa.Column('approval_type', sa.String(length=255), nullable=False),
sa.Column('approved_date', sa.DateTime(), nullable=False),
sa.Column('notes', UTF8LongText(), nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('pk_servicekeyapproval')),
)
op.bulk_insert(
tables.notificationkind,
[{'name':'service_key_submitted'}],
)
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(
'servicekey',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('kid', sa.String(length=255), nullable=False),
sa.Column('service', sa.String(length=255), nullable=False),
sa.Column('jwk', UTF8LongText(), nullable=False),
sa.Column('metadata', UTF8LongText(), nullable=False),
sa.Column('created_date', sa.DateTime(), nullable=False),
sa.Column('expiration_date', sa.DateTime(), nullable=True),
sa.Column('approval_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['approval_id'], ['servicekeyapproval.id'],
name=op.f('fk_servicekey_approval_id_servicekeyapproval')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_servicekey')),
)
op.create_index('servicekey_approval_id', 'servicekey', ['approval_id'], unique=False)
op.create_index('servicekey_kid', 'servicekey', ['kid'], unique=True)
op.create_index('servicekey_service', 'servicekey', ['service'], unique=False)
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)
def downgrade(tables):
op.drop_column(u'notification', 'lookup_path')
op.drop_table('servicekey')
op.drop_table('servicekeyapproval')