Python alembic.context.get_context() Examples

The following are 30 code examples of alembic.context.get_context(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module alembic.context , or try the search function .
Example #1
Source File: 914b8f02df38_new_table_for_lifetime_model_exceptions.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        create_table('lifetime_except',
                     sa.Column('id', GUID()),
                     sa.Column('scope', sa.String(25)),
                     sa.Column('name', sa.String(255)),
                     sa.Column('did_type', DIDType.db_type()),
                     sa.Column('account', sa.String(25)),
                     sa.Column('comments', sa.String(4000)),
                     sa.Column('pattern', sa.String(255)),
                     sa.Column('state', LifetimeExceptionsState.db_type()),
                     sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow),
                     sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow),
                     sa.Column('expires_at', sa.DateTime))

        create_primary_key('LIFETIME_EXCEPT_PK', 'lifetime_except', ['id', 'scope', 'name', 'did_type', 'account'])
        create_check_constraint('LIFETIME_EXCEPT_SCOPE_NN', 'lifetime_except', 'scope is not null')
        create_check_constraint('LIFETIME_EXCEPT_NAME_NN', 'lifetime_except', 'name is not null')
        create_check_constraint('LIFETIME_EXCEPT_DID_TYPE_NN', 'lifetime_except', 'did_type is not null') 
Example #2
Source File: 45378a1e76a8_create_collection_replica_table.py    From rucio with Apache License 2.0 6 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name == 'oracle':
        drop_constraint('COLLECTION_REPLICAS_STATE_CHK', 'collection_replicas', type_='check')
        drop_table('collection_replicas')

    elif context.get_context().dialect.name == 'postgresql':
        schema = context.get_context().version_table_schema + '.' if context.get_context().version_table_schema else ''
        op.execute('ALTER TABLE ' + schema + 'collection_replicas ALTER COLUMN state TYPE CHAR')  # pylint: disable=no-member
        drop_constraint('COLLECTION_REPLICAS_STATE_CHK', 'collection_replicas', type_='check')
        drop_table('collection_replicas')

    elif context.get_context().dialect.name == 'mysql':
        drop_table('collection_replicas') 
Example #3
Source File: 3ad36e2268b0_create_collection_replicas_updates_table.py    From rucio with Apache License 2.0 6 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''

    if context.get_context().dialect.name in ['oracle', 'postgresql']:
        drop_column('collection_replicas', 'available_replicas_cnt', schema=schema)
        drop_column('collection_replicas', 'available_bytes', schema=schema)
        drop_table('updated_col_rep')

    elif context.get_context().dialect.name == 'mysql':
        drop_column('collection_replicas', 'available_replicas_cnt', schema=schema)
        drop_column('collection_replicas', 'available_bytes', schema=schema)
        drop_constraint('UPDATED_COL_REP_PK', 'updated_col_rep', type_='primary')
        drop_index('UPDATED_COL_REP_SNR_IDX', 'updated_col_rep')
        drop_table('updated_col_rep') 
Example #4
Source File: 21d6b9dc9961_add_mismatch_scheme_state_to_requests.py    From rucio with Apache License 2.0 6 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    schema = context.get_context().version_table_schema + '.' if context.get_context().version_table_schema else ''

    if context.get_context().dialect.name == 'oracle':
        drop_constraint('REQUESTS_STATE_CHK', 'requests', type_='check')
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L', 'N', 'O', 'A', 'U', 'W')")

    elif context.get_context().dialect.name == 'postgresql':
        op.execute('ALTER TABLE ' + schema + 'requests DROP CONSTRAINT IF EXISTS "REQUESTS_STATE_CHK", ALTER COLUMN state TYPE CHAR')  # pylint: disable=no-member
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L', 'N', 'O', 'A', 'U', 'W')")

    elif context.get_context().dialect.name == 'mysql' and context.get_context().dialect.server_version_info[0] == 5:
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L', 'N', 'O', 'A', 'U', 'W')")

    elif context.get_context().dialect.name == 'mysql' and context.get_context().dialect.server_version_info[0] == 8:
        op.execute('ALTER TABLE ' + schema + 'requests DROP CHECK REQUESTS_STATE_CHK')  # pylint: disable=no-member
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L', 'N', 'O', 'A', 'U', 'W')") 
Example #5
Source File: 21d6b9dc9961_add_mismatch_scheme_state_to_requests.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    schema = context.get_context().version_table_schema + '.' if context.get_context().version_table_schema else ''

    if context.get_context().dialect.name in ['oracle', 'postgresql']:
        drop_constraint('REQUESTS_STATE_CHK', 'requests', type_='check')
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L', 'N', 'O', 'A', 'U', 'W', 'M')")

    elif context.get_context().dialect.name == 'mysql' and context.get_context().dialect.server_version_info[0] == 5:
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L', 'N', 'O', 'A', 'U', 'W', 'M')")

    elif context.get_context().dialect.name == 'mysql' and context.get_context().dialect.server_version_info[0] == 8:
        op.execute('ALTER TABLE ' + schema + 'requests DROP CHECK REQUESTS_STATE_CHK')  # pylint: disable=no-member
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L', 'N', 'O', 'A', 'U', 'W', 'M')") 
Example #6
Source File: 3345511706b8_replicas_table_pk_definition_is_in_.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'postgresql']:
        drop_constraint('SOURCES_REPLICA_FK', 'sources', type_='foreignkey')
        drop_constraint('REPLICAS_PK', 'replicas', type_='primary')
        create_primary_key('REPLICAS_PK', 'replicas', ['scope', 'name', 'rse_id'])
        create_foreign_key('SOURCES_REPLICA_FK', 'sources', 'replicas', ['scope', 'name', 'rse_id'], ['scope', 'name', 'rse_id'])

    elif context.get_context().dialect.name == 'mysql':
        drop_constraint('SOURCES_REPLICA_FK', 'sources', type_='foreignkey')
        # The constraint has an internal index which is not automatically dropped,
        # we have to do that manually
        drop_index('SOURCES_REPLICA_FK', 'sources')
        drop_constraint(constraint_name='REPLICAS_LFN_FK', table_name='replicas', type_='foreignkey')
        drop_constraint(constraint_name='REPLICAS_RSE_ID_FK', table_name='replicas', type_='foreignkey')
        drop_constraint('REPLICAS_PK', 'replicas', type_='primary')
        create_foreign_key('REPLICAS_LFN_FK', 'replicas', 'dids', ['scope', 'name'], ['scope', 'name'])
        create_foreign_key('REPLICAS_RSE_ID_FK', 'replicas', 'rses', ['rse_id'], ['id'])
        create_primary_key('REPLICAS_PK', 'replicas', ['scope', 'name', 'rse_id'])
        create_foreign_key('SOURCES_REPLICA_FK', 'sources', 'replicas', ['scope', 'name', 'rse_id'], ['scope', 'name', 'rse_id']) 
Example #7
Source File: 3345511706b8_replicas_table_pk_definition_is_in_.py    From rucio with Apache License 2.0 6 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'postgresql']:
        drop_constraint(constraint_name='SOURCES_REPLICA_FK', table_name='sources', type_='foreignkey')
        drop_constraint(constraint_name='REPLICAS_PK', table_name='replicas', type_='primary')
        create_primary_key('REPLICAS_PK', 'replicas', ['rse_id', 'scope', 'name'])
        create_foreign_key('SOURCES_REPLICA_FK', 'sources', 'replicas', ['rse_id', 'scope', 'name'], ['rse_id', 'scope', 'name'])

    elif context.get_context().dialect.name == 'mysql':
        drop_constraint(constraint_name='SOURCES_REPLICA_FK', table_name='sources', type_='foreignkey')
        # The constraint has an internal index which is not automatically dropped,
        # we have to do that manually
        drop_index('SOURCES_REPLICA_FK', 'sources')
        drop_constraint(constraint_name='REPLICAS_LFN_FK', table_name='replicas', type_='foreignkey')
        drop_constraint(constraint_name='REPLICAS_RSE_ID_FK', table_name='replicas', type_='foreignkey')
        drop_constraint(constraint_name='REPLICAS_PK', table_name='replicas', type_='primary')
        create_foreign_key('REPLICAS_LFN_FK', 'replicas', 'dids', ['scope', 'name'], ['scope', 'name'])
        create_foreign_key('REPLICAS_RSE_ID_FK', 'replicas', 'rses', ['rse_id'], ['id'])
        create_primary_key('REPLICAS_PK', 'replicas', ['rse_id', 'scope', 'name'])
        create_foreign_key('SOURCES_REPLICA_FK', 'sources', 'replicas', ['rse_id', 'scope', 'name'], ['rse_id', 'scope', 'name']) 
Example #8
Source File: 3c9df354071b_extend_waiting_request_state.py    From rucio with Apache License 2.0 6 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    schema = context.get_context().version_table_schema + '.' if context.get_context().version_table_schema else ''

    if context.get_context().dialect.name in ['oracle', 'postgresql']:
        drop_constraint('REQUESTS_STATE_CHK', 'requests', type_='check')
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L', 'N', 'O', 'A', 'U')")

    elif context.get_context().dialect.name == 'mysql' and context.get_context().dialect.server_version_info[0] == 5:
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L', 'N', 'O', 'A', 'U')")

    elif context.get_context().dialect.name == 'mysql' and context.get_context().dialect.server_version_info[0] == 8:
        op.execute('ALTER TABLE ' + schema + 'requests DROP CHECK REQUESTS_STATE_CHK')  # pylint: disable=no-member
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L', 'N', 'O', 'A', 'U')") 
Example #9
Source File: bf3baa1c1474_correct_pk_and_idx_for_history_tables.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        # CONTENTS_HISTORY
        drop_constraint('CONTENTS_HIST_PK', 'contents_history', type_='primary')

        # ARCHIVE_CONTENTS_HISTORY
        drop_constraint(constraint_name='ARCH_CONT_HIST_PK', table_name='archive_contents_history', type_='primary')

        # RULES_HIST_RECENT
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        drop_constraint(constraint_name='RULES_HIST_RECENT_PK', table_name='rules_hist_recent', type_='primary')
        drop_column('rules_hist_recent', 'history_id', schema=schema)

        # RULES_HISTORY
        drop_column('rules_history', 'history_id', schema=schema) 
Example #10
Source File: bf3baa1c1474_correct_pk_and_idx_for_history_tables.py    From rucio with Apache License 2.0 6 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        # CONTENTS_HISTORY
        create_primary_key('CONTENTS_HIST_PK', 'contents_history', ['scope', 'name', 'child_scope', 'child_name'])

        # ARCHIVE_CONTENTS_HISTORY
        create_primary_key('ARCH_CONT_HIST_PK', 'archive_contents_history', ['scope', 'name', 'child_scope', 'child_name'])
        drop_index('ARCH_CONT_HIST_IDX', 'archive_contents_history')

        # RULES_HIST_RECENT
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        add_column('rules_hist_recent', sa.Column('history_id', GUID()), schema=schema)
        create_primary_key('RULES_HIST_RECENT_PK', 'rules_hist_recent', ['history_id'])

        # RULES_HISTORY
        add_column('rules_history', sa.Column('history_id', GUID()), schema=schema)
        create_primary_key('RULES_HIST_LONGTERM_PK', 'rules_history', ['history_id'])

        # MESSAGES_HISTORY
        create_primary_key('MESSAGES_HIST_ID_PK', 'messages_history', ['id']) 
Example #11
Source File: 1d96f484df21_asynchronous_rules_and_rule_approval.py    From rucio with Apache License 2.0 6 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    schema = context.get_context().version_table_schema + '.' if context.get_context().version_table_schema else ''

    if context.get_context().dialect.name == 'oracle':
        drop_column('rules', 'ignore_account_limit')
        drop_constraint('RULES_STATE_CHK', 'rules')
        create_check_constraint('RULES_STATE_CHK', 'rules', "state IN ('S', 'R', 'U', 'O')")

    elif context.get_context().dialect.name == 'postgresql':
        drop_column('rules', 'ignore_account_limit', schema=schema[:-1])
        op.execute('ALTER TABLE ' + schema + 'rules DROP CONSTRAINT IF EXISTS "RULES_STATE_CHK", ALTER COLUMN state TYPE CHAR')  # pylint: disable=no-member
        create_check_constraint('RULES_STATE_CHK', 'rules', "state IN ('S', 'R', 'U', 'O')")

    elif context.get_context().dialect.name == 'mysql' and context.get_context().dialect.server_version_info[0] == 5:
        drop_column('rules', 'ignore_account_limit', schema=schema[:-1])
        create_check_constraint('RULES_STATE_CHK', 'rules', "state IN ('S', 'R', 'U', 'O')")

    elif context.get_context().dialect.name == 'mysql' and context.get_context().dialect.server_version_info[0] == 8:
        drop_column('rules', 'ignore_account_limit', schema=schema[:-1])
        op.execute('ALTER TABLE ' + schema + 'rules DROP CHECK RULES_STATE_CHK')  # pylint: disable=no-member
        create_check_constraint('RULES_STATE_CHK', 'rules', "state IN ('S', 'R', 'U', 'O')") 
Example #12
Source File: 1d96f484df21_asynchronous_rules_and_rule_approval.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    schema = context.get_context().version_table_schema + '.' if context.get_context().version_table_schema else ''

    if context.get_context().dialect.name == 'oracle':
        add_column('rules', sa.Column('ignore_account_limit', sa.Boolean(name='RULES_IGNORE_ACCOUNT_LIMIT_CHK'), default=False))
        drop_constraint('RULES_STATE_CHK', 'rules')
        create_check_constraint('RULES_STATE_CHK', 'rules', "state IN ('S', 'R', 'U', 'O', 'W', 'I')")

    elif context.get_context().dialect.name == 'postgresql':
        add_column('rules', sa.Column('ignore_account_limit', sa.Boolean(name='RULES_IGNORE_ACCOUNT_LIMIT_CHK'), default=False), schema=schema[:-1])
        drop_constraint('RULES_STATE_CHK', 'rules')
        create_check_constraint('RULES_STATE_CHK', 'rules', "state IN ('S', 'R', 'U', 'O', 'W', 'I')")

    elif context.get_context().dialect.name == 'mysql' and context.get_context().dialect.server_version_info[0] == 5:
        add_column('rules', sa.Column('ignore_account_limit', sa.Boolean(name='RULES_IGNORE_ACCOUNT_LIMIT_CHK'), default=False), schema=schema[:-1])
        create_check_constraint('RULES_STATE_CHK', 'rules', "state IN ('S', 'R', 'U', 'O', 'W', 'I')")

    elif context.get_context().dialect.name == 'mysql' and context.get_context().dialect.server_version_info[0] == 8:
        add_column('rules', sa.Column('ignore_account_limit', sa.Boolean(name='RULES_IGNORE_ACCOUNT_LIMIT_CHK'), default=False), schema=schema[:-1])
        op.execute('ALTER TABLE ' + schema + 'rules DROP CHECK RULES_STATE_CHK')  # pylint: disable=no-member
        create_check_constraint('RULES_STATE_CHK', 'rules', "state IN ('S', 'R', 'U', 'O', 'W', 'I')") 
Example #13
Source File: 4c3a4acfe006_new_attr_account_table.py    From rucio with Apache License 2.0 6 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        drop_table('account_attr_map')

    elif context.get_context().dialect.name == 'postgresql':
        # drop_constraint('ACCOUNT_ATTR_MAP_PK', 'account_attr_map', type_='primary')
        # drop_constraint('ACCOUNT_ATTR_MAP_CREATED_NN', 'account_attr_map')
        # drop_constraint('ACCOUNT_ATTR_MAP_UPDATED_NN', 'account_attr_map')
        # drop_constraint('ACCOUNT_ATTR_MAP_ACCOUNT_FK', 'account_attr_map')
        # drop_index('ACCOUNT_ATTR_MAP_KEY_VALUE_IDX', 'account_attr_map')
        # drop_table('account_attr_map')
        pass 
Example #14
Source File: 914b8f02df38_new_table_for_lifetime_model_exceptions.py    From rucio with Apache License 2.0 5 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        drop_table('lifetime_except') 
Example #15
Source File: 102efcf145f4_added_stuck_at_column_to_rules.py    From rucio with Apache License 2.0 5 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        add_column('rules', sa.Column('stuck_at', sa.DateTime), schema=schema) 
Example #16
Source File: c129ccdb2d5_add_lumiblocknr_to_dids.py    From rucio with Apache License 2.0 5 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        add_column('dids', sa.Column('lumiblocknr', sa.Integer()), schema=schema) 
Example #17
Source File: c129ccdb2d5_add_lumiblocknr_to_dids.py    From rucio with Apache License 2.0 5 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        drop_column('dids', 'lumiblocknr', schema=schema) 
Example #18
Source File: 42db2617c364_create_index_on_requests_external_id.py    From rucio with Apache License 2.0 5 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        drop_index('REQUESTS_EXTERNALID_UQ', 'requests') 
Example #19
Source File: bb695f45c04_extend_request_state.py    From rucio with Apache License 2.0 5 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    schema = context.get_context().version_table_schema + '.' if context.get_context().version_table_schema else ''

    if context.get_context().dialect.name == 'oracle':
        drop_constraint('REQUESTS_STATE_CHK', 'requests', type_='check')
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L')")
        drop_column('requests', 'submitter_id')
        drop_column('sources', 'is_using')

    elif context.get_context().dialect.name == 'postgresql':
        drop_constraint('REQUESTS_STATE_CHK', 'requests', type_='check')
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L')")
        drop_column('requests', 'submitter_id', schema=schema[:-1])
        drop_column('sources', 'is_using', schema=schema[:-1])

    elif context.get_context().dialect.name == 'mysql' and context.get_context().dialect.server_version_info[0] == 5:
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L')")
        drop_column('requests', 'submitter_id', schema=schema[:-1])
        drop_column('sources', 'is_using', schema=schema[:-1])

    elif context.get_context().dialect.name == 'mysql' and context.get_context().dialect.server_version_info[0] == 8:
        op.execute('ALTER TABLE ' + schema + 'requests DROP CHECK REQUESTS_STATE_CHK')  # pylint: disable=no-member
        create_check_constraint(constraint_name='REQUESTS_STATE_CHK', table_name='requests',
                                condition="state in ('Q', 'G', 'S', 'D', 'F', 'L')")
        drop_column('requests', 'submitter_id', schema=schema[:-1])
        drop_column('sources', 'is_using', schema=schema[:-1]) 
Example #20
Source File: a616581ee47_added_columns_to_table_requests.py    From rucio with Apache License 2.0 5 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        drop_column('requests', 'bytes', schema=schema)
        drop_column('requests', 'md5', schema=schema)
        drop_column('requests', 'adler32', schema=schema)
        drop_column('requests', 'dest_url', schema=schema)
        drop_column('requests_history', 'bytes', schema=schema)
        drop_column('requests_history', 'md5', schema=schema)
        drop_column('requests_history', 'adler32', schema=schema)
        drop_column('requests_history', 'dest_url', schema=schema) 
Example #21
Source File: a616581ee47_added_columns_to_table_requests.py    From rucio with Apache License 2.0 5 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        add_column('requests', sa.Column('bytes', sa.BigInteger), schema=schema)
        add_column('requests', sa.Column('md5', String(32)), schema=schema)
        add_column('requests', sa.Column('adler32', String(8)), schema=schema)
        add_column('requests', sa.Column('dest_url', String(2048)), schema=schema)
        add_column('requests_history', sa.Column('bytes', sa.BigInteger), schema=schema)
        add_column('requests_history', sa.Column('md5', String(32)), schema=schema)
        add_column('requests_history', sa.Column('adler32', String(8)), schema=schema)
        add_column('requests_history', sa.Column('dest_url', String(2048)), schema=schema) 
Example #22
Source File: 32c7d2783f7e_create_bad_replicas_table.py    From rucio with Apache License 2.0 5 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        drop_table('bad_replicas') 
Example #23
Source File: 3ac1660a1a72_extend_distance_table.py    From rucio with Apache License 2.0 5 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        drop_column('distances', 'packet_loss', schema=schema)
        drop_column('distances', 'latency', schema=schema)
        drop_column('distances', 'mbps_file', schema=schema)
        drop_column('distances', 'mbps_link', schema=schema)
        drop_column('distances', 'queued_total', schema=schema)
        drop_column('distances', 'done_1h', schema=schema)
        drop_column('distances', 'done_6h', schema=schema) 
Example #24
Source File: 4a7182d9578b_added_bytes_length_accessed_at_columns.py    From rucio with Apache License 2.0 5 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        add_column('dataset_locks', sa.Column('length', sa.BigInteger()), schema=schema)
        add_column('dataset_locks', sa.Column('bytes', sa.BigInteger()), schema=schema)
        add_column('dataset_locks', sa.Column('accessed_at', sa.DateTime()), schema=schema)
        add_column('dids', sa.Column('accessed_at', sa.DateTime()), schema=schema) 
Example #25
Source File: 25fc855625cf_added_unique_constraint_to_rules.py    From rucio with Apache License 2.0 5 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        drop_index('RULES_SC_NA_AC_RS_CO_UQ_IDX', 'rules') 
Example #26
Source File: 2eef46be23d4_change_tokens_pk.py    From rucio with Apache License 2.0 5 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        drop_constraint('TOKENS_ACCOUNT_FK', 'tokens', type_='foreignkey')
        drop_constraint('TOKENS_PK', 'tokens', type_='primary')
        create_primary_key('TOKENS_PK', 'tokens', ['token'])
        create_foreign_key('TOKENS_ACCOUNT_FK', 'tokens', 'accounts', ['account'], ['account']) 
Example #27
Source File: 2eef46be23d4_change_tokens_pk.py    From rucio with Apache License 2.0 5 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        drop_constraint('TOKENS_ACCOUNT_FK', 'tokens', type_='foreignkey')
        drop_constraint('TOKENS_PK', 'tokens', type_='primary')
        create_primary_key('TOKENS_PK', 'tokens', ['account', 'token'])
        create_foreign_key('TOKENS_ACCOUNT_FK', 'tokens', 'accounts', ['account'], ['account']) 
Example #28
Source File: 6e572a9bfbf3_add_new_split_container_column_to_rules.py    From rucio with Apache License 2.0 5 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        drop_column('rules', 'split_container', schema=schema)
        drop_column('rules_hist_recent', 'split_container', schema=schema)
        drop_column('rules_history', 'split_container', schema=schema) 
Example #29
Source File: 3ac1660a1a72_extend_distance_table.py    From rucio with Apache License 2.0 5 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        add_column('distances', sa.Column('packet_loss', sa.Integer), schema=schema)
        add_column('distances', sa.Column('latency', sa.Integer), schema=schema)
        add_column('distances', sa.Column('mbps_file', sa.Integer), schema=schema)
        add_column('distances', sa.Column('mbps_link', sa.Integer), schema=schema)
        add_column('distances', sa.Column('queued_total', sa.Integer), schema=schema)
        add_column('distances', sa.Column('done_1h', sa.Integer), schema=schema)
        add_column('distances', sa.Column('done_6h', sa.Integer), schema=schema) 
Example #30
Source File: 4a7182d9578b_added_bytes_length_accessed_at_columns.py    From rucio with Apache License 2.0 5 votes vote down vote up
def downgrade():
    '''
    Downgrade the database to the previous revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        drop_column('dataset_locks', 'length', schema=schema)
        drop_column('dataset_locks', 'bytes', schema=schema)
        drop_column('dataset_locks', 'accessed_at', schema=schema)
        drop_column('dids', 'accessed_at', schema=schema)