d2880807b2
- Small fixes to ensure Quay works for Postgres
608 lines
33 KiB
Python
608 lines
33 KiB
Python
"""Set up initial database
|
|
|
|
Revision ID: 5a07499ce53f
|
|
Revises: None
|
|
Create Date: 2014-05-13 11:26:51.808426
|
|
|
|
"""
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '5a07499ce53f'
|
|
down_revision = None
|
|
|
|
from alembic import op
|
|
from data.model.sqlalchemybridge import gen_sqlalchemy_metadata
|
|
from data.database import all_models
|
|
import sqlalchemy as sa
|
|
|
|
|
|
def upgrade():
|
|
schema = gen_sqlalchemy_metadata(all_models)
|
|
|
|
### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('loginservice',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('loginservice_name', 'loginservice', ['name'], unique=True)
|
|
|
|
op.bulk_insert(schema.tables['loginservice'],
|
|
[
|
|
{'id':1, 'name':'github'},
|
|
{'id':2, 'name':'quayrobot'},
|
|
{'id':3, 'name':'ldap'},
|
|
])
|
|
|
|
op.create_table('imagestorage',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('uuid', sa.String(length=255), nullable=False),
|
|
sa.Column('checksum', sa.String(length=255), nullable=True),
|
|
sa.Column('created', sa.DateTime(), nullable=True),
|
|
sa.Column('comment', sa.Text(), nullable=True),
|
|
sa.Column('command', sa.Text(), nullable=True),
|
|
sa.Column('image_size', sa.BigInteger(), nullable=True),
|
|
sa.Column('uploading', sa.Boolean(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('queueitem',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('queue_name', sa.String(length=1024), nullable=False),
|
|
sa.Column('body', sa.Text(), nullable=False),
|
|
sa.Column('available_after', sa.DateTime(), nullable=False),
|
|
sa.Column('available', sa.Boolean(), nullable=False),
|
|
sa.Column('processing_expires', sa.DateTime(), nullable=True),
|
|
sa.Column('retries_remaining', sa.Integer(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('queueitem_available', 'queueitem', ['available'], unique=False)
|
|
op.create_index('queueitem_available_after', 'queueitem', ['available_after'], unique=False)
|
|
op.create_index('queueitem_processing_expires', 'queueitem', ['processing_expires'], unique=False)
|
|
op.create_index('queueitem_queue_name', 'queueitem', ['queue_name'], unique=False)
|
|
op.create_table('role',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('role_name', 'role', ['name'], unique=False)
|
|
|
|
op.bulk_insert(schema.tables['role'],
|
|
[
|
|
{'id':1, 'name':'admin'},
|
|
{'id':2, 'name':'write'},
|
|
{'id':3, 'name':'read'},
|
|
])
|
|
|
|
op.create_table('logentrykind',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('logentrykind_name', 'logentrykind', ['name'], unique=False)
|
|
|
|
op.bulk_insert(schema.tables['logentrykind'],
|
|
[
|
|
{'id':1, 'name':'account_change_plan'},
|
|
{'id':2, 'name':'account_change_cc'},
|
|
{'id':3, 'name':'account_change_password'},
|
|
{'id':4, 'name':'account_convert'},
|
|
|
|
{'id':5, 'name':'create_robot'},
|
|
{'id':6, 'name':'delete_robot'},
|
|
|
|
{'id':7, 'name':'create_repo'},
|
|
{'id':8, 'name':'push_repo'},
|
|
{'id':9, 'name':'pull_repo'},
|
|
{'id':10, 'name':'delete_repo'},
|
|
{'id':11, 'name':'create_tag'},
|
|
{'id':12, 'name':'move_tag'},
|
|
{'id':13, 'name':'delete_tag'},
|
|
{'id':14, 'name':'add_repo_permission'},
|
|
{'id':15, 'name':'change_repo_permission'},
|
|
{'id':16, 'name':'delete_repo_permission'},
|
|
{'id':17, 'name':'change_repo_visibility'},
|
|
{'id':18, 'name':'add_repo_accesstoken'},
|
|
{'id':19, 'name':'delete_repo_accesstoken'},
|
|
{'id':20, 'name':'add_repo_webhook'},
|
|
{'id':21, 'name':'delete_repo_webhook'},
|
|
{'id':22, 'name':'set_repo_description'},
|
|
|
|
{'id':23, 'name':'build_dockerfile'},
|
|
|
|
{'id':24, 'name':'org_create_team'},
|
|
{'id':25, 'name':'org_delete_team'},
|
|
{'id':26, 'name':'org_add_team_member'},
|
|
{'id':27, 'name':'org_remove_team_member'},
|
|
{'id':28, 'name':'org_set_team_description'},
|
|
{'id':29, 'name':'org_set_team_role'},
|
|
|
|
{'id':30, 'name':'create_prototype_permission'},
|
|
{'id':31, 'name':'modify_prototype_permission'},
|
|
{'id':32, 'name':'delete_prototype_permission'},
|
|
|
|
{'id':33, 'name':'setup_repo_trigger'},
|
|
{'id':34, 'name':'delete_repo_trigger'},
|
|
|
|
{'id':35, 'name':'create_application'},
|
|
{'id':36, 'name':'update_application'},
|
|
{'id':37, 'name':'delete_application'},
|
|
{'id':38, 'name':'reset_application_client_secret'},
|
|
])
|
|
|
|
op.create_table('notificationkind',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('notificationkind_name', 'notificationkind', ['name'], unique=False)
|
|
|
|
op.bulk_insert(schema.tables['notificationkind'],
|
|
[
|
|
{'id':1, 'name':'password_required'},
|
|
{'id':2, 'name':'over_private_usage'},
|
|
{'id':3, 'name':'expiring_license'},
|
|
])
|
|
|
|
op.create_table('teamrole',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('teamrole_name', 'teamrole', ['name'], unique=False)
|
|
|
|
op.bulk_insert(schema.tables['teamrole'],
|
|
[
|
|
{'id':1, 'name':'admin'},
|
|
{'id':2, 'name':'creator'},
|
|
{'id':3, 'name':'member'},
|
|
])
|
|
|
|
op.create_table('visibility',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('visibility_name', 'visibility', ['name'], unique=False)
|
|
|
|
op.bulk_insert(schema.tables['visibility'],
|
|
[
|
|
{'id':1, 'name':'public'},
|
|
{'id':2, 'name':'private'},
|
|
])
|
|
|
|
op.create_table('user',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('username', sa.String(length=255), nullable=False),
|
|
sa.Column('password_hash', sa.String(length=255), nullable=True),
|
|
sa.Column('email', sa.String(length=255), nullable=False),
|
|
sa.Column('verified', sa.Boolean(), nullable=False),
|
|
sa.Column('stripe_id', sa.String(length=255), nullable=True),
|
|
sa.Column('organization', sa.Boolean(), nullable=False),
|
|
sa.Column('robot', sa.Boolean(), nullable=False),
|
|
sa.Column('invoice_email', sa.Boolean(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('user_email', 'user', ['email'], unique=True)
|
|
op.create_index('user_organization', 'user', ['organization'], unique=False)
|
|
op.create_index('user_robot', 'user', ['robot'], unique=False)
|
|
op.create_index('user_stripe_id', 'user', ['stripe_id'], unique=False)
|
|
op.create_index('user_username', 'user', ['username'], unique=True)
|
|
op.create_table('buildtriggerservice',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('buildtriggerservice_name', 'buildtriggerservice', ['name'], unique=False)
|
|
|
|
op.bulk_insert(schema.tables['buildtriggerservice'],
|
|
[
|
|
{'id':1, 'name':'github'},
|
|
])
|
|
|
|
op.create_table('federatedlogin',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('service_id', sa.Integer(), nullable=False),
|
|
sa.Column('service_ident', sa.String(length=255), nullable=False),
|
|
sa.ForeignKeyConstraint(['service_id'], ['loginservice.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('federatedlogin_service_id', 'federatedlogin', ['service_id'], unique=False)
|
|
op.create_index('federatedlogin_service_id_service_ident', 'federatedlogin', ['service_id', 'service_ident'], unique=True)
|
|
op.create_index('federatedlogin_service_id_user_id', 'federatedlogin', ['service_id', 'user_id'], unique=True)
|
|
op.create_index('federatedlogin_user_id', 'federatedlogin', ['user_id'], unique=False)
|
|
op.create_table('oauthapplication',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('client_id', sa.String(length=255), nullable=False),
|
|
sa.Column('client_secret', sa.String(length=255), nullable=False),
|
|
sa.Column('redirect_uri', sa.String(length=255), nullable=False),
|
|
sa.Column('application_uri', sa.String(length=255), nullable=False),
|
|
sa.Column('organization_id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=False),
|
|
sa.Column('gravatar_email', sa.String(length=255), nullable=True),
|
|
sa.ForeignKeyConstraint(['organization_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('oauthapplication_client_id', 'oauthapplication', ['client_id'], unique=False)
|
|
op.create_index('oauthapplication_organization_id', 'oauthapplication', ['organization_id'], unique=False)
|
|
op.create_table('notification',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('uuid', sa.String(length=255), nullable=False),
|
|
sa.Column('kind_id', sa.Integer(), nullable=False),
|
|
sa.Column('target_id', sa.Integer(), nullable=False),
|
|
sa.Column('metadata_json', sa.Text(), nullable=False),
|
|
sa.Column('created', sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(['kind_id'], ['notificationkind.id'], ),
|
|
sa.ForeignKeyConstraint(['target_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('notification_created', 'notification', ['created'], unique=False)
|
|
op.create_index('notification_kind_id', 'notification', ['kind_id'], unique=False)
|
|
op.create_index('notification_target_id', 'notification', ['target_id'], unique=False)
|
|
op.create_index('notification_uuid', 'notification', ['uuid'], unique=False)
|
|
op.create_table('emailconfirmation',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('code', sa.String(length=255), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('pw_reset', sa.Boolean(), nullable=False),
|
|
sa.Column('new_email', sa.String(length=255), nullable=True),
|
|
sa.Column('email_confirm', sa.Boolean(), nullable=False),
|
|
sa.Column('created', sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('emailconfirmation_code', 'emailconfirmation', ['code'], unique=True)
|
|
op.create_index('emailconfirmation_user_id', 'emailconfirmation', ['user_id'], unique=False)
|
|
op.create_table('team',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.Column('organization_id', sa.Integer(), nullable=False),
|
|
sa.Column('role_id', sa.Integer(), nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=False),
|
|
sa.ForeignKeyConstraint(['organization_id'], ['user.id'], ),
|
|
sa.ForeignKeyConstraint(['role_id'], ['teamrole.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('team_name', 'team', ['name'], unique=False)
|
|
op.create_index('team_name_organization_id', 'team', ['name', 'organization_id'], unique=True)
|
|
op.create_index('team_organization_id', 'team', ['organization_id'], unique=False)
|
|
op.create_index('team_role_id', 'team', ['role_id'], unique=False)
|
|
op.create_table('repository',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('namespace', sa.String(length=255), nullable=False),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.Column('visibility_id', sa.Integer(), nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.Column('badge_token', sa.String(length=255), nullable=False),
|
|
sa.ForeignKeyConstraint(['visibility_id'], ['visibility.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('repository_namespace_name', 'repository', ['namespace', 'name'], unique=True)
|
|
op.create_index('repository_visibility_id', 'repository', ['visibility_id'], unique=False)
|
|
op.create_table('accesstoken',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('friendly_name', sa.String(length=255), nullable=True),
|
|
sa.Column('code', sa.String(length=255), nullable=False),
|
|
sa.Column('repository_id', sa.Integer(), nullable=False),
|
|
sa.Column('created', sa.DateTime(), nullable=False),
|
|
sa.Column('role_id', sa.Integer(), nullable=False),
|
|
sa.Column('temporary', sa.Boolean(), nullable=False),
|
|
sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
|
|
sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('accesstoken_code', 'accesstoken', ['code'], unique=True)
|
|
op.create_index('accesstoken_repository_id', 'accesstoken', ['repository_id'], unique=False)
|
|
op.create_index('accesstoken_role_id', 'accesstoken', ['role_id'], unique=False)
|
|
op.create_table('repositorypermission',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('team_id', sa.Integer(), nullable=True),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('repository_id', sa.Integer(), nullable=False),
|
|
sa.Column('role_id', sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
|
|
sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
|
|
sa.ForeignKeyConstraint(['team_id'], ['team.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('repositorypermission_repository_id', 'repositorypermission', ['repository_id'], unique=False)
|
|
op.create_index('repositorypermission_role_id', 'repositorypermission', ['role_id'], unique=False)
|
|
op.create_index('repositorypermission_team_id', 'repositorypermission', ['team_id'], unique=False)
|
|
op.create_index('repositorypermission_team_id_repository_id', 'repositorypermission', ['team_id', 'repository_id'], unique=True)
|
|
op.create_index('repositorypermission_user_id', 'repositorypermission', ['user_id'], unique=False)
|
|
op.create_index('repositorypermission_user_id_repository_id', 'repositorypermission', ['user_id', 'repository_id'], unique=True)
|
|
op.create_table('oauthaccesstoken',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('uuid', sa.String(length=255), nullable=False),
|
|
sa.Column('application_id', sa.Integer(), nullable=False),
|
|
sa.Column('authorized_user_id', sa.Integer(), nullable=False),
|
|
sa.Column('scope', sa.String(length=255), nullable=False),
|
|
sa.Column('access_token', sa.String(length=255), nullable=False),
|
|
sa.Column('token_type', sa.String(length=255), nullable=False),
|
|
sa.Column('expires_at', sa.DateTime(), nullable=False),
|
|
sa.Column('refresh_token', sa.String(length=255), nullable=True),
|
|
sa.Column('data', sa.Text(), nullable=False),
|
|
sa.ForeignKeyConstraint(['application_id'], ['oauthapplication.id'], ),
|
|
sa.ForeignKeyConstraint(['authorized_user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('oauthaccesstoken_access_token', 'oauthaccesstoken', ['access_token'], unique=False)
|
|
op.create_index('oauthaccesstoken_application_id', 'oauthaccesstoken', ['application_id'], unique=False)
|
|
op.create_index('oauthaccesstoken_authorized_user_id', 'oauthaccesstoken', ['authorized_user_id'], unique=False)
|
|
op.create_index('oauthaccesstoken_refresh_token', 'oauthaccesstoken', ['refresh_token'], unique=False)
|
|
op.create_index('oauthaccesstoken_uuid', 'oauthaccesstoken', ['uuid'], unique=False)
|
|
op.create_table('teammember',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('team_id', sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(['team_id'], ['team.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('teammember_team_id', 'teammember', ['team_id'], unique=False)
|
|
op.create_index('teammember_user_id', 'teammember', ['user_id'], unique=False)
|
|
op.create_index('teammember_user_id_team_id', 'teammember', ['user_id', 'team_id'], unique=True)
|
|
op.create_table('webhook',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('public_id', sa.String(length=255), nullable=False),
|
|
sa.Column('repository_id', sa.Integer(), nullable=False),
|
|
sa.Column('parameters', sa.Text(), nullable=False),
|
|
sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('webhook_public_id', 'webhook', ['public_id'], unique=True)
|
|
op.create_index('webhook_repository_id', 'webhook', ['repository_id'], unique=False)
|
|
op.create_table('oauthauthorizationcode',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('application_id', sa.Integer(), nullable=False),
|
|
sa.Column('code', sa.String(length=255), nullable=False),
|
|
sa.Column('scope', sa.String(length=255), nullable=False),
|
|
sa.Column('data', sa.Text(), nullable=False),
|
|
sa.ForeignKeyConstraint(['application_id'], ['oauthapplication.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('oauthauthorizationcode_application_id', 'oauthauthorizationcode', ['application_id'], unique=False)
|
|
op.create_index('oauthauthorizationcode_code', 'oauthauthorizationcode', ['code'], unique=False)
|
|
op.create_table('image',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('docker_image_id', sa.String(length=255), nullable=False),
|
|
sa.Column('checksum', sa.String(length=255), nullable=True),
|
|
sa.Column('created', sa.DateTime(), nullable=True),
|
|
sa.Column('comment', sa.Text(), nullable=True),
|
|
sa.Column('command', sa.Text(), nullable=True),
|
|
sa.Column('repository_id', sa.Integer(), nullable=False),
|
|
sa.Column('image_size', sa.BigInteger(), nullable=True),
|
|
sa.Column('ancestors', sa.String(length=60535), nullable=True),
|
|
sa.Column('storage_id', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
|
|
sa.ForeignKeyConstraint(['storage_id'], ['imagestorage.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('image_ancestors', 'image', ['ancestors'], unique=False)
|
|
op.create_index('image_repository_id', 'image', ['repository_id'], unique=False)
|
|
op.create_index('image_repository_id_docker_image_id', 'image', ['repository_id', 'docker_image_id'], unique=False)
|
|
op.create_index('image_storage_id', 'image', ['storage_id'], unique=False)
|
|
op.create_table('permissionprototype',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('org_id', sa.Integer(), nullable=False),
|
|
sa.Column('uuid', sa.String(length=255), nullable=False),
|
|
sa.Column('activating_user_id', sa.Integer(), nullable=True),
|
|
sa.Column('delegate_user_id', sa.Integer(), nullable=True),
|
|
sa.Column('delegate_team_id', sa.Integer(), nullable=True),
|
|
sa.Column('role_id', sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(['activating_user_id'], ['user.id'], ),
|
|
sa.ForeignKeyConstraint(['delegate_team_id'], ['team.id'], ),
|
|
sa.ForeignKeyConstraint(['delegate_user_id'], ['user.id'], ),
|
|
sa.ForeignKeyConstraint(['org_id'], ['user.id'], ),
|
|
sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('permissionprototype_activating_user_id', 'permissionprototype', ['activating_user_id'], unique=False)
|
|
op.create_index('permissionprototype_delegate_team_id', 'permissionprototype', ['delegate_team_id'], unique=False)
|
|
op.create_index('permissionprototype_delegate_user_id', 'permissionprototype', ['delegate_user_id'], unique=False)
|
|
op.create_index('permissionprototype_org_id', 'permissionprototype', ['org_id'], unique=False)
|
|
op.create_index('permissionprototype_org_id_activating_user_id', 'permissionprototype', ['org_id', 'activating_user_id'], unique=False)
|
|
op.create_index('permissionprototype_role_id', 'permissionprototype', ['role_id'], unique=False)
|
|
op.create_table('repositorytag',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.Column('image_id', sa.Integer(), nullable=False),
|
|
sa.Column('repository_id', sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(['image_id'], ['image.id'], ),
|
|
sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('repositorytag_image_id', 'repositorytag', ['image_id'], unique=False)
|
|
op.create_index('repositorytag_repository_id', 'repositorytag', ['repository_id'], unique=False)
|
|
op.create_index('repositorytag_repository_id_name', 'repositorytag', ['repository_id', 'name'], unique=True)
|
|
op.create_table('logentry',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('kind_id', sa.Integer(), nullable=False),
|
|
sa.Column('account_id', sa.Integer(), nullable=False),
|
|
sa.Column('performer_id', sa.Integer(), nullable=True),
|
|
sa.Column('repository_id', sa.Integer(), nullable=True),
|
|
sa.Column('access_token_id', sa.Integer(), nullable=True),
|
|
sa.Column('datetime', sa.DateTime(), nullable=False),
|
|
sa.Column('ip', sa.String(length=255), nullable=True),
|
|
sa.Column('metadata_json', sa.Text(), nullable=False),
|
|
sa.ForeignKeyConstraint(['access_token_id'], ['accesstoken.id'], ),
|
|
sa.ForeignKeyConstraint(['account_id'], ['user.id'], ),
|
|
sa.ForeignKeyConstraint(['kind_id'], ['logentrykind.id'], ),
|
|
sa.ForeignKeyConstraint(['performer_id'], ['user.id'], ),
|
|
sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('logentry_access_token_id', 'logentry', ['access_token_id'], unique=False)
|
|
op.create_index('logentry_account_id', 'logentry', ['account_id'], unique=False)
|
|
op.create_index('logentry_datetime', 'logentry', ['datetime'], unique=False)
|
|
op.create_index('logentry_kind_id', 'logentry', ['kind_id'], unique=False)
|
|
op.create_index('logentry_performer_id', 'logentry', ['performer_id'], unique=False)
|
|
op.create_index('logentry_repository_id', 'logentry', ['repository_id'], unique=False)
|
|
op.create_table('repositorybuildtrigger',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('uuid', sa.String(length=255), nullable=False),
|
|
sa.Column('service_id', sa.Integer(), nullable=False),
|
|
sa.Column('repository_id', sa.Integer(), nullable=False),
|
|
sa.Column('connected_user_id', sa.Integer(), nullable=False),
|
|
sa.Column('auth_token', sa.String(length=255), nullable=False),
|
|
sa.Column('config', sa.Text(), nullable=False),
|
|
sa.Column('write_token_id', sa.Integer(), nullable=True),
|
|
sa.Column('pull_robot_id', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['connected_user_id'], ['user.id'], ),
|
|
sa.ForeignKeyConstraint(['pull_robot_id'], ['user.id'], ),
|
|
sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
|
|
sa.ForeignKeyConstraint(['service_id'], ['buildtriggerservice.id'], ),
|
|
sa.ForeignKeyConstraint(['write_token_id'], ['accesstoken.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('repositorybuildtrigger_connected_user_id', 'repositorybuildtrigger', ['connected_user_id'], unique=False)
|
|
op.create_index('repositorybuildtrigger_pull_robot_id', 'repositorybuildtrigger', ['pull_robot_id'], unique=False)
|
|
op.create_index('repositorybuildtrigger_repository_id', 'repositorybuildtrigger', ['repository_id'], unique=False)
|
|
op.create_index('repositorybuildtrigger_service_id', 'repositorybuildtrigger', ['service_id'], unique=False)
|
|
op.create_index('repositorybuildtrigger_write_token_id', 'repositorybuildtrigger', ['write_token_id'], unique=False)
|
|
op.create_table('repositorybuild',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('uuid', sa.String(length=255), nullable=False),
|
|
sa.Column('repository_id', sa.Integer(), nullable=False),
|
|
sa.Column('access_token_id', sa.Integer(), nullable=False),
|
|
sa.Column('resource_key', sa.String(length=255), nullable=False),
|
|
sa.Column('job_config', sa.Text(), nullable=False),
|
|
sa.Column('phase', sa.String(length=255), nullable=False),
|
|
sa.Column('started', sa.DateTime(), nullable=False),
|
|
sa.Column('display_name', sa.String(length=255), nullable=False),
|
|
sa.Column('trigger_id', sa.Integer(), nullable=True),
|
|
sa.Column('pull_robot_id', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['access_token_id'], ['accesstoken.id'], ),
|
|
sa.ForeignKeyConstraint(['pull_robot_id'], ['user.id'], ),
|
|
sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
|
|
sa.ForeignKeyConstraint(['trigger_id'], ['repositorybuildtrigger.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('repositorybuild_access_token_id', 'repositorybuild', ['access_token_id'], unique=False)
|
|
op.create_index('repositorybuild_pull_robot_id', 'repositorybuild', ['pull_robot_id'], unique=False)
|
|
op.create_index('repositorybuild_repository_id', 'repositorybuild', ['repository_id'], unique=False)
|
|
op.create_index('repositorybuild_resource_key', 'repositorybuild', ['resource_key'], unique=False)
|
|
op.create_index('repositorybuild_trigger_id', 'repositorybuild', ['trigger_id'], unique=False)
|
|
op.create_index('repositorybuild_uuid', 'repositorybuild', ['uuid'], unique=False)
|
|
### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index('repositorybuild_uuid', table_name='repositorybuild')
|
|
op.drop_index('repositorybuild_trigger_id', table_name='repositorybuild')
|
|
op.drop_index('repositorybuild_resource_key', table_name='repositorybuild')
|
|
op.drop_index('repositorybuild_repository_id', table_name='repositorybuild')
|
|
op.drop_index('repositorybuild_pull_robot_id', table_name='repositorybuild')
|
|
op.drop_index('repositorybuild_access_token_id', table_name='repositorybuild')
|
|
op.drop_table('repositorybuild')
|
|
op.drop_index('repositorybuildtrigger_write_token_id', table_name='repositorybuildtrigger')
|
|
op.drop_index('repositorybuildtrigger_service_id', table_name='repositorybuildtrigger')
|
|
op.drop_index('repositorybuildtrigger_repository_id', table_name='repositorybuildtrigger')
|
|
op.drop_index('repositorybuildtrigger_pull_robot_id', table_name='repositorybuildtrigger')
|
|
op.drop_index('repositorybuildtrigger_connected_user_id', table_name='repositorybuildtrigger')
|
|
op.drop_table('repositorybuildtrigger')
|
|
op.drop_index('logentry_repository_id', table_name='logentry')
|
|
op.drop_index('logentry_performer_id', table_name='logentry')
|
|
op.drop_index('logentry_kind_id', table_name='logentry')
|
|
op.drop_index('logentry_datetime', table_name='logentry')
|
|
op.drop_index('logentry_account_id', table_name='logentry')
|
|
op.drop_index('logentry_access_token_id', table_name='logentry')
|
|
op.drop_table('logentry')
|
|
op.drop_index('repositorytag_repository_id_name', table_name='repositorytag')
|
|
op.drop_index('repositorytag_repository_id', table_name='repositorytag')
|
|
op.drop_index('repositorytag_image_id', table_name='repositorytag')
|
|
op.drop_table('repositorytag')
|
|
op.drop_index('permissionprototype_role_id', table_name='permissionprototype')
|
|
op.drop_index('permissionprototype_org_id_activating_user_id', table_name='permissionprototype')
|
|
op.drop_index('permissionprototype_org_id', table_name='permissionprototype')
|
|
op.drop_index('permissionprototype_delegate_user_id', table_name='permissionprototype')
|
|
op.drop_index('permissionprototype_delegate_team_id', table_name='permissionprototype')
|
|
op.drop_index('permissionprototype_activating_user_id', table_name='permissionprototype')
|
|
op.drop_table('permissionprototype')
|
|
op.drop_index('image_storage_id', table_name='image')
|
|
op.drop_index('image_repository_id_docker_image_id', table_name='image')
|
|
op.drop_index('image_repository_id', table_name='image')
|
|
op.drop_index('image_ancestors', table_name='image')
|
|
op.drop_table('image')
|
|
op.drop_index('oauthauthorizationcode_code', table_name='oauthauthorizationcode')
|
|
op.drop_index('oauthauthorizationcode_application_id', table_name='oauthauthorizationcode')
|
|
op.drop_table('oauthauthorizationcode')
|
|
op.drop_index('webhook_repository_id', table_name='webhook')
|
|
op.drop_index('webhook_public_id', table_name='webhook')
|
|
op.drop_table('webhook')
|
|
op.drop_index('teammember_user_id_team_id', table_name='teammember')
|
|
op.drop_index('teammember_user_id', table_name='teammember')
|
|
op.drop_index('teammember_team_id', table_name='teammember')
|
|
op.drop_table('teammember')
|
|
op.drop_index('oauthaccesstoken_uuid', table_name='oauthaccesstoken')
|
|
op.drop_index('oauthaccesstoken_refresh_token', table_name='oauthaccesstoken')
|
|
op.drop_index('oauthaccesstoken_authorized_user_id', table_name='oauthaccesstoken')
|
|
op.drop_index('oauthaccesstoken_application_id', table_name='oauthaccesstoken')
|
|
op.drop_index('oauthaccesstoken_access_token', table_name='oauthaccesstoken')
|
|
op.drop_table('oauthaccesstoken')
|
|
op.drop_index('repositorypermission_user_id_repository_id', table_name='repositorypermission')
|
|
op.drop_index('repositorypermission_user_id', table_name='repositorypermission')
|
|
op.drop_index('repositorypermission_team_id_repository_id', table_name='repositorypermission')
|
|
op.drop_index('repositorypermission_team_id', table_name='repositorypermission')
|
|
op.drop_index('repositorypermission_role_id', table_name='repositorypermission')
|
|
op.drop_index('repositorypermission_repository_id', table_name='repositorypermission')
|
|
op.drop_table('repositorypermission')
|
|
op.drop_index('accesstoken_role_id', table_name='accesstoken')
|
|
op.drop_index('accesstoken_repository_id', table_name='accesstoken')
|
|
op.drop_index('accesstoken_code', table_name='accesstoken')
|
|
op.drop_table('accesstoken')
|
|
op.drop_index('repository_visibility_id', table_name='repository')
|
|
op.drop_index('repository_namespace_name', table_name='repository')
|
|
op.drop_table('repository')
|
|
op.drop_index('team_role_id', table_name='team')
|
|
op.drop_index('team_organization_id', table_name='team')
|
|
op.drop_index('team_name_organization_id', table_name='team')
|
|
op.drop_index('team_name', table_name='team')
|
|
op.drop_table('team')
|
|
op.drop_index('emailconfirmation_user_id', table_name='emailconfirmation')
|
|
op.drop_index('emailconfirmation_code', table_name='emailconfirmation')
|
|
op.drop_table('emailconfirmation')
|
|
op.drop_index('notification_uuid', table_name='notification')
|
|
op.drop_index('notification_target_id', table_name='notification')
|
|
op.drop_index('notification_kind_id', table_name='notification')
|
|
op.drop_index('notification_created', table_name='notification')
|
|
op.drop_table('notification')
|
|
op.drop_index('oauthapplication_organization_id', table_name='oauthapplication')
|
|
op.drop_index('oauthapplication_client_id', table_name='oauthapplication')
|
|
op.drop_table('oauthapplication')
|
|
op.drop_index('federatedlogin_user_id', table_name='federatedlogin')
|
|
op.drop_index('federatedlogin_service_id_user_id', table_name='federatedlogin')
|
|
op.drop_index('federatedlogin_service_id_service_ident', table_name='federatedlogin')
|
|
op.drop_index('federatedlogin_service_id', table_name='federatedlogin')
|
|
op.drop_table('federatedlogin')
|
|
op.drop_index('buildtriggerservice_name', table_name='buildtriggerservice')
|
|
op.drop_table('buildtriggerservice')
|
|
op.drop_index('user_username', table_name='user')
|
|
op.drop_index('user_stripe_id', table_name='user')
|
|
op.drop_index('user_robot', table_name='user')
|
|
op.drop_index('user_organization', table_name='user')
|
|
op.drop_index('user_email', table_name='user')
|
|
op.drop_table('user')
|
|
op.drop_index('visibility_name', table_name='visibility')
|
|
op.drop_table('visibility')
|
|
op.drop_index('teamrole_name', table_name='teamrole')
|
|
op.drop_table('teamrole')
|
|
op.drop_index('notificationkind_name', table_name='notificationkind')
|
|
op.drop_table('notificationkind')
|
|
op.drop_index('logentrykind_name', table_name='logentrykind')
|
|
op.drop_table('logentrykind')
|
|
op.drop_index('role_name', table_name='role')
|
|
op.drop_table('role')
|
|
op.drop_index('queueitem_queue_name', table_name='queueitem')
|
|
op.drop_index('queueitem_processing_expires', table_name='queueitem')
|
|
op.drop_index('queueitem_available_after', table_name='queueitem')
|
|
op.drop_index('queueitem_available', table_name='queueitem')
|
|
op.drop_table('queueitem')
|
|
op.drop_table('imagestorage')
|
|
op.drop_index('loginservice_name', table_name='loginservice')
|
|
op.drop_table('loginservice')
|
|
### end Alembic commands ###
|