def upgrade():
migration_context = context.get_context()
if migration_context.dialect.name == 'sqlite':
id_type = sa.Integer
else:
id_type = sa.BigInteger
op.create_table('coverages',
sa.Column('id', id_type, autoincrement=True,
primary_key=True),
sa.Column('project_name', sa.String(256), nullable=False),
sa.Column('coverage_rate', sa.Float()),
sa.Column('report_time', sa.DateTime()),
sa.Column('report_time_microsecond', sa.Integer(),
default=0),
mysql_engine='InnoDB')
op.create_index('ix_project_name', 'coverages', ['project_name'])
python类get_context()的实例源码
52dfb338f74e_add_coverages_table.py 文件源码
项目:coverage2sql
作者: openstack
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def upgrade():
migration_context = context.get_context()
if migration_context.dialect.name == 'sqlite':
id_type = sa.Integer
else:
id_type = sa.BigInteger
op.create_table('files',
sa.Column('id', id_type, autoincrement=True,
primary_key=True),
sa.Column('coverage_id', id_type, nullable=False),
sa.Column('filename', sa.String(256), nullable=False),
sa.Column('line_rate', sa.Float()),
mysql_engine='InnoDB')
op.create_index('ix_class_coverage_id', 'files', ['coverage_id'])
op.create_index('ix_filename', 'files', ['filename'])
def upgrade():
'''
upgrade method
'''
create_table('rse_transfer_limits',
sa.Column('rse_id', GUID()),
sa.Column('activity', sa.String(50)),
sa.Column('rse_expression', sa.String(3000)),
sa.Column('max_transfers', sa.BigInteger),
sa.Column('transfers', sa.BigInteger),
sa.Column('waitings', sa.BigInteger),
sa.Column('updated_at', sa.DateTime),
sa.Column('created_at', sa.DateTime))
if context.get_context().dialect.name != 'sqlite':
create_primary_key('RSE_TRANSFER_LIMITS_PK', 'rse_transfer_limits', ['rse_id', 'activity'])
create_check_constraint('RSE_TRANSFER_LIMITS_CREATED_NN', 'rse_transfer_limits', 'created_at is not null')
create_check_constraint('RSE_TRANSFER_LIMITS_UPDATED_NN', 'rse_transfer_limits', 'updated_at is not null')
create_foreign_key('RSE_TRANSFER_LIMITS_RSE_ID_FK', 'rse_transfer_limits', 'rses', ['rse_id'], ['id'])
def upgrade():
'''
upgrade method
'''
create_table('bad_replicas',
sa.Column('scope', sa.String(25)),
sa.Column('name', sa.String(255)),
sa.Column('rse_id', GUID()),
sa.Column('reason', sa.String(255)),
sa.Column('state', sa.String(1)),
sa.Column('account', sa.String(25)),
sa.Column('updated_at', sa.DateTime),
sa.Column('created_at', sa.DateTime))
if context.get_context().dialect.name not in ('sqlite'):
create_primary_key('BAD_REPLICAS_STATE_PK', 'bad_replicas', ['scope', 'name', 'rse_id', 'created_at'])
create_check_constraint('BAD_REPLICAS_SCOPE_NN', 'bad_replicas', 'scope is not null')
create_check_constraint('BAD_REPLICAS_NAME_NN', 'bad_replicas', 'name is not null')
create_check_constraint('BAD_REPLICAS_RSE_ID_NN', 'bad_replicas', 'rse_id is not null')
create_foreign_key('BAD_REPLICAS_ACCOUNT_FK', 'bad_replicas', 'accounts', ['account'], ['account'])
create_index('BAD_REPLICAS_STATE_IDX', 'bad_replicas', ['rse_id', 'state'])
def upgrade():
'''
upgrade method
'''
if context.get_context().dialect.name not in ['sqlite']:
create_table('sources_history',
sa.Column('request_id', GUID()),
sa.Column('scope', sa.String(25)),
sa.Column('name', sa.String(255)),
sa.Column('rse_id', GUID()),
sa.Column('dest_rse_id', GUID()),
sa.Column('url', sa.String(2048)),
sa.Column('bytes', sa.BigInteger),
sa.Column('ranking', sa.Integer()),
sa.Column('is_using', sa.Boolean(), default=False))
add_column('requests', sa.Column('estimated_at', sa.DateTime))
add_column('requests_history', sa.Column('estimated_at', sa.DateTime))
def upgrade():
'''
upgrade method
'''
create_table('heartbeats',
sa.Column('executable', sa.String(512)),
sa.Column('hostname', sa.String(128)),
sa.Column('pid', sa.Integer(), autoincrement=False),
sa.Column('thread_id', sa.BigInteger(), autoincrement=False),
sa.Column('thread_name', sa.String(64)),
sa.Column('updated_at', sa.DateTime),
sa.Column('created_at', sa.DateTime))
if context.get_context().dialect.name != 'sqlite':
create_primary_key('heartbeats_pk', 'heartbeats', ['executable', 'hostname', 'pid', 'thread_id'])
create_index('heartbeats_updated_at', 'heartbeats', ['updated_at'])
if context.get_context().dialect.name != 'mysql':
create_check_constraint('heartbeats_created_nn', 'heartbeats', 'created_at is not null')
create_check_constraint('heartbeats_updated_nn', 'heartbeats', 'updated_at is not null')
def downgrade():
'''
downgrade method
'''
if context.get_context().dialect.name not in ('sqlite', 'mysql'):
drop_constraint('messages_event_type_nn', 'messages', type_='check')
drop_constraint('messages_payload_nn', 'messages', type_='check')
drop_constraint('messages_created_nn', 'messages', type_='check')
drop_constraint('messages_updated_nn', 'messages', type_='check')
if context.get_context().dialect.name != 'sqlite':
drop_constraint('messages_pk', 'messages', type_='primary')
rename_table('messages', 'callbacks')
if context.get_context().dialect.name != 'sqlite':
create_primary_key('callbacks_pk', 'callbacks', ['id'])
create_check_constraint('callbacks_event_type_nn', 'callbacks', 'event_type is not null')
create_check_constraint('callbacks_payload_nn', 'callbacks', 'payload is not null')
create_check_constraint('callbacks_created_nn', 'callbacks', 'created_at is not null')
create_check_constraint('callbacks_updated_nn', 'callbacks', 'updated_at is not null')
45378a1e76a8_create_collection_replica_table.py 文件源码
项目:rucio
作者: rucio01
项目源码
文件源码
阅读 61
收藏 0
点赞 0
评论 0
def upgrade():
'''
upgrade method
'''
create_table('collection_replicas',
sa.Column('scope', sa.String(25)),
sa.Column('name', sa.String(255)),
sa.Column('did_type', DIDType.db_type(name='COLLECTION_REPLICAS_TYPE_CHK')),
sa.Column('rse_id', GUID()),
sa.Column('bytes', sa.BigInteger),
sa.Column('length', sa.BigInteger),
sa.Column('state', ReplicaState.db_type(name='COLLECTION_REPLICAS_STATE_CHK'), default=ReplicaState.UNAVAILABLE),
sa.Column('accessed_at', sa.DateTime),
sa.Column('updated_at', sa.DateTime),
sa.Column('created_at', sa.DateTime))
if context.get_context().dialect.name != 'sqlite':
create_primary_key('COLLECTION_REPLICAS_PK', 'collection_replicas', ['scope', 'name', 'rse_id'])
create_foreign_key('COLLECTION_REPLICAS_LFN_FK', 'collection_replicas', 'dids', ['scope', 'name'], ['scope', 'name'])
create_foreign_key('COLLECTION_REPLICAS_RSE_ID_FK', 'collection_replicas', 'rses', ['rse_id'], ['id'])
create_check_constraint('COLLECTION_REPLICAS_SIZE_NN', 'collection_replicas', 'bytes IS NOT NULL')
create_check_constraint('COLLECTION_REPLICAS_STATE_NN', 'collection_replicas', 'state IS NOT NULL')
create_index('COLLECTION_REPLICAS_RSE_ID_IDX', 'collection_replicas', ['rse_id'])
def downgrade():
'''
downgrade method
'''
if context.get_context().dialect.name == 'postgresql':
drop_constraint('ACCOUNT_LIMITS_PK', 'account_limits', type_='primary')
drop_constraint('ACCOUNT_LIMITS_CREATED_NN', 'account_limits')
drop_constraint('ACCOUNT_LIMITS_UPDATED_NN', 'account_limits')
drop_constraint('ACCOUNT_LIMITS_ACCOUNT_FK', 'account_limits')
drop_constraint('ACCOUNT_LIMITS_RSE_ID_FK', 'account_limits')
drop_table('account_limits')
create_table('account_limits',
sa.Column('account', sa.String(25)),
sa.Column('rse_expression', sa.String(255)),
sa.Column('name', sa.String(255)),
sa.Column('value', sa.BigInteger),
sa.Column('updated_at', sa.DateTime),
sa.Column('created_at', sa.DateTime))
if context.get_context().dialect.name != 'sqlite':
create_primary_key('ACCOUNT_LIMITS_PK', 'account_limits', ['account', 'rse_expression', 'name'])
create_check_constraint('ACCOUNT_LIMITS_CREATED_NN', 'account_limits', 'created_at is not null')
create_check_constraint('ACCOUNT_LIMITS_UPDATED_NN', 'account_limits', 'updated_at is not null')
create_foreign_key('ACCOUNT_LIMITS_ACCOUNT_FK', 'account_limits', 'accounts', ['account'], ['account'])
3082b8cef557_add_naming_convention_table_and_closed_.py 文件源码
项目:rucio
作者: rucio01
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def upgrade():
'''
upgrade method
'''
if context.get_context().dialect.name != 'sqlite':
add_column('dids', sa.Column('closed_at', sa.DateTime))
add_column('contents_history', sa.Column('deleted_at', sa.DateTime))
create_table('naming_conventions',
sa.Column('scope', sa.String(25)),
sa.Column('regexp', sa.String(255)),
sa.Column('convention_type', sa.String(1)),
sa.Column('updated_at', sa.DateTime),
sa.Column('created_at', sa.DateTime))
create_primary_key('NAMING_CONVENTIONS_PK', 'naming_conventions', ['scope'])
create_foreign_key('NAMING_CONVENTIONS_SCOPE_FK', 'naming_conventions',
'scopes', ['scope'], ['scope'])
create_check_constraint('NAMING_CONVENTIONS_CREATED_NN', 'naming_conventions',
'created_at is not null')
create_check_constraint('NAMING_CONVENTIONS_UPDATED_NN', 'naming_conventions',
'updated_at is not null')
def upgrade():
'''
upgrade method
'''
create_table('configs',
sa.Column('section', sa.String(128)),
sa.Column('opt', sa.String(128)),
sa.Column('value', sa.String(4000)),
sa.Column('updated_at', sa.DateTime),
sa.Column('created_at', sa.DateTime))
if context.get_context().dialect.name != 'sqlite':
create_primary_key('configs_pk', 'configs', ['section', 'opt'])
create_check_constraint('configs_created_nn', 'configs', 'created_at is not null')
create_check_constraint('configs_updated_nn', 'configs', 'updated_at is not null')
create_table('configs_history',
sa.Column('section', sa.String(128)),
sa.Column('opt', sa.String(128)),
sa.Column('value', sa.String(4000)),
sa.Column('updated_at', sa.DateTime),
sa.Column('created_at', sa.DateTime))
if context.get_context().dialect.name != 'sqlite':
create_primary_key('configs_history_pk', 'configs_history', ['section', 'opt', 'updated_at'])
def upgrade():
'''
upgrade method
'''
create_table('account_attr_map',
sa.Column('account', sa.String(25)),
sa.Column('key', sa.String(255)),
sa.Column('value', sa.String(255)),
sa.Column('updated_at', sa.DateTime),
sa.Column('created_at', sa.DateTime))
if context.get_context().dialect.name != 'sqlite':
create_primary_key('ACCOUNT_ATTR_MAP_PK', 'account_attr_map', ['account', 'key'])
create_check_constraint('ACCOUNT_ATTR_MAP_CREATED_NN', 'account_attr_map', 'created_at is not null')
create_check_constraint('ACCOUNT_ATTR_MAP_UPDATED_NN', 'account_attr_map', 'updated_at is not null')
create_foreign_key('ACCOUNT_ATTR_MAP_ACCOUNT_FK', 'account_attr_map', 'accounts', ['account'], ['account'])
create_index('ACCOUNT_ATTR_MAP_KEY_VALUE_IDX', 'account_attr_map', ['key', 'value'])
def upgrade():
'''
upgrade method
'''
create_table('distances',
sa.Column('src_rse_id', GUID()),
sa.Column('dest_rse_id', GUID()),
sa.Column('ranking', sa.Integer),
sa.Column('agis_distance', sa.Integer),
sa.Column('geoip_distance', sa.Integer),
sa.Column('updated_at', sa.DateTime),
sa.Column('created_at', sa.DateTime))
if context.get_context().dialect.name != 'sqlite':
create_primary_key('DISTANCES_PK', 'distances', ['src_rse_id', 'dest_rse_id'])
create_foreign_key('DISTANCES_SRC_RSES_FK', 'distances', 'rses', ['src_rse_id'], ['id'])
create_foreign_key('DISTANCES_DEST_RSES_FK', 'distances', 'rses', ['dest_rse_id'], ['id'])
create_check_constraint('DISTANCES_CREATED_NN', 'distances', 'created_at is not null')
create_check_constraint('DISTANCES_UPDATED_NN', 'distances', 'updated_at is not null')
create_index('DISTANCES_DEST_RSEID_IDX', 'distances', ['dest_rse_id'])
3ad36e2268b0_create_collection_replicas_updates_table.py 文件源码
项目:rucio
作者: rucio01
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
def upgrade():
'''
upgrade method
'''
if context.get_context().dialect.name != 'sqlite':
add_column('collection_replicas', sa.Column('available_replicas_cnt', sa.BigInteger()))
add_column('collection_replicas', sa.Column('available_bytes', sa.BigInteger()))
create_table('updated_col_rep',
sa.Column('id', GUID()),
sa.Column('scope', sa.String(25)),
sa.Column('name', sa.String(255)),
sa.Column('did_type', DIDType.db_type(name='UPDATED_COL_REP_TYPE_CHK')),
sa.Column('rse_id', GUID()),
sa.Column('updated_at', sa.DateTime),
sa.Column('created_at', sa.DateTime))
if context.get_context().dialect.name != 'sqlite':
create_primary_key('UPDATED_COL_REP_PK', 'updated_col_rep', ['id'])
create_check_constraint('UPDATED_COL_REP_SCOPE_NN', 'updated_col_rep', 'scope IS NOT NULL')
create_check_constraint('UPDATED_COL_REP_NAME_NN', 'updated_col_rep', 'name IS NOT NULL')
create_index('UPDATED_COL_REP_SNR_IDX', 'updated_col_rep', ['scope', 'name', 'rse_id'])
def upgrade():
'''
upgrade method
'''
create_table('sources',
sa.Column('request_id', GUID()),
sa.Column('scope', sa.String(25)),
sa.Column('name', sa.String(255)),
sa.Column('rse_id', GUID()),
sa.Column('dest_rse_id', GUID()),
sa.Column('url', sa.String(2048)),
sa.Column('ranking', sa.Integer),
sa.Column('bytes', sa.BigInteger),
sa.Column('updated_at', sa.DateTime),
sa.Column('created_at', sa.DateTime))
if context.get_context().dialect.name != 'sqlite':
create_primary_key('SOURCES_PK', 'sources', ['request_id', 'rse_id', 'scope', 'name'])
create_foreign_key('SOURCES_REQ_ID_FK', 'sources', 'requests', ['request_id'], ['id'])
create_foreign_key('SOURCES_REPLICAS_FK', 'sources', 'replicas', ['scope', 'name', 'rse_id'], ['scope', 'name', 'rse_id'])
create_foreign_key('SOURCES_RSES_FK', 'sources', 'rses', ['rse_id'], ['id'])
create_foreign_key('SOURCES_DST_RSES_FK', 'sources', 'rses', ['dest_rse_id'], ['id'])
create_check_constraint('SOURCES_CREATED_NN', 'sources', 'created_at is not null')
create_check_constraint('SOURCES_UPDATED_NN', 'sources', 'updated_at is not null')
create_index('SOURCES_SRC_DST_IDX', 'sources', ['rse_id', 'dest_rse_id'])
def upgrade():
"""Upgrade database."""
# The following is a ridiculous hack to force table recreation for SQLite to
# enable the use of a default timestamp.
recreate = 'auto'
migrate_context = context.get_context()
sqlite_dialect_class = None
if getattr(sa.dialects, 'sqlite', False):
sqlite_dialect_class = (sa.dialects.sqlite.pysqlite
.SQLiteDialect_pysqlite)
if migrate_context.dialect.__class__ == sqlite_dialect_class:
recreate = 'always'
with op.batch_alter_table('games', recreate=recreate) as batch_op:
batch_op.add_column(sa.Column('played_at', sa.DateTime(),
nullable=False, server_default=sa.func.now()))
def upgrade():
"""Upgrade database."""
# The following is a ridiculous hack to force table recreation for SQLite to
# enable the use of a default timestamp.
recreate = 'auto'
migrate_context = context.get_context()
sqlite_dialect_class = None
if getattr(sa.dialects, 'sqlite', False):
sqlite_dialect_class = (sa.dialects.sqlite.pysqlite
.SQLiteDialect_pysqlite)
if migrate_context.dialect.__class__ == sqlite_dialect_class:
recreate = 'always'
with op.batch_alter_table('games', recreate=recreate) as batch_op:
batch_op.add_column(sa.Column('last_modified_at', sa.DateTime(),
nullable=False, server_default=sa.func.now()))
def upgrade():
"""Upgrade database."""
# The following is a ridiculous hack to force table recreation for SQLite to
# enable the use of a default timestamp.
recreate = 'auto'
migrate_context = context.get_context()
sqlite_dialect_class = None
if getattr(sa.dialects, 'sqlite', False):
sqlite_dialect_class = (sa.dialects.sqlite.pysqlite
.SQLiteDialect_pysqlite)
if migrate_context.dialect.__class__ == sqlite_dialect_class:
recreate = 'always'
with op.batch_alter_table('games', recreate=recreate) as batch_op:
batch_op.add_column(sa.Column('created_at', sa.DateTime(),
nullable=False, server_default=sa.func.now()))
25821a8a45a3_remove_unique_constraint_on_requests.py 文件源码
项目:rucio
作者: rucio01
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def upgrade():
'''
upgrade method
'''
if context.get_context().dialect.name != 'sqlite':
# mysql has to remove FK constraint to drop IDX
drop_constraint('REQUESTS_RSES_FK', 'requests', type_='foreignkey')
drop_constraint('REQUESTS_DID_FK', 'requests', type_='foreignkey')
drop_constraint('REQUESTS_SC_NA_RS_TY_UQ_IDX', 'requests', type_='unique')
create_foreign_key('REQUESTS_RSES_FK', 'requests', 'rses', ['dest_rse_id'], ['id'])
create_foreign_key('REQUESTS_DID_FK', 'requests', 'dids', ['scope', 'name'], ['scope', 'name'])
create_index('REQUESTS_SCOPE_NAME_RSE_IDX', 'requests', ['scope', 'name', 'dest_rse_id', 'request_type'])
25821a8a45a3_remove_unique_constraint_on_requests.py 文件源码
项目:rucio
作者: rucio01
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
def downgrade():
'''
downgrade method
'''
if context.get_context().dialect.name != 'sqlite':
# mysql has to remove FK constraint to drop IDX
drop_constraint('REQUESTS_RSES_FK', 'requests', type_='foreignkey')
drop_constraint('REQUESTS_DID_FK', 'requests', type_='foreignkey')
drop_index('REQUESTS_SCOPE_NAME_RSE_IDX', 'requests')
create_foreign_key('REQUESTS_RSES_FK', 'requests', 'rses', ['dest_rse_id'], ['id'])
create_foreign_key('REQUESTS_DID_FK', 'requests', 'dids', ['scope', 'name'], ['scope', 'name'])
create_unique_constraint('REQUESTS_SC_NA_RS_TY_UQ_IDX', 'requests', ['scope', 'name', 'dest_rse_id', 'request_type'])
def downgrade():
'''
downgrade method
'''
if context.get_context().dialect.name == 'postgresql':
drop_constraint('RSE_TRANSFER_LIMITS_PK', 'rse_transfer_limits', type_='primary')
drop_constraint('RSE_TRANSFER_LIMITS_CREATED_NN', 'rse_transfer_limits')
drop_constraint('RSE_TRANSFER_LIMITS_UPDATED_NN', 'rse_transfer_limits')
drop_constraint('RSE_TRANSFER_LIMITS_RSE_ID_FK', 'rse_transfer_limits')
drop_table('rse_transfer_limits')
def downgrade():
'''
downgrade method
'''
if context.get_context().dialect.name != 'sqlite':
drop_column('rules', 'activity')
ae2a56fcc89_added_comment_column_to_rules.py 文件源码
项目:rucio
作者: rucio01
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
def downgrade():
'''
downgrade method
'''
if context.get_context().dialect.name != 'sqlite':
drop_column('rules', 'comments')
drop_column('rules_hist_recent', 'comments')
drop_column('rules_history', 'comments')
70587619328_add_comment_column_for_subscriptions.py 文件源码
项目:rucio
作者: rucio01
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def downgrade():
'''
downgrade method
'''
if context.get_context().dialect.name != 'sqlite':
drop_column('subscriptions', 'comments')
156fb5b5a14_add_request_type_to_requests_idx.py 文件源码
项目:rucio
作者: rucio01
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
def upgrade():
'''
upgrade method
'''
if context.get_context().dialect.name != 'sqlite':
# mysql has to remove FK constraint to drop IDX
drop_constraint('REQUESTS_RSES_FK', 'requests', type_='foreignkey')
drop_constraint('REQUESTS_DID_FK', 'requests', type_='foreignkey')
drop_index('REQUESTS_SCOPE_NAME_RSE_IDX', 'requests')
create_foreign_key('REQUESTS_RSES_FK', 'requests', 'rses', ['dest_rse_id'], ['id'])
create_foreign_key('REQUESTS_DID_FK', 'requests', 'dids', ['scope', 'name'], ['scope', 'name'])
create_unique_constraint('REQUESTS_SC_NA_RS_TY_UQ_IDX', 'requests', ['scope', 'name', 'dest_rse_id', 'request_type'])
156fb5b5a14_add_request_type_to_requests_idx.py 文件源码
项目:rucio
作者: rucio01
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def downgrade():
'''
downgrade method
'''
if context.get_context().dialect.name != 'sqlite':
# mysql has to remove FK constraint to drop IDX
drop_constraint('REQUESTS_RSES_FK', 'requests', type_='foreignkey')
drop_constraint('REQUESTS_DID_FK', 'requests', type_='foreignkey')
drop_constraint('REQUESTS_SC_NA_RS_TY_UQ_IDX', 'requests', type_='unique')
create_foreign_key('REQUESTS_RSES_FK', 'requests', 'rses', ['dest_rse_id'], ['id'])
create_foreign_key('REQUESTS_DID_FK', 'requests', 'dids', ['scope', 'name'], ['scope', 'name'])
create_index('REQUESTS_SCOPE_NAME_RSE_IDX', 'requests', ['scope', 'name', 'dest_rse_id', 'request_type'])
def downgrade():
'''
downgrade method
'''
if context.get_context().dialect.name not in ['sqlite']:
drop_column('requests', 'estimated_at')
drop_column('requests_history', 'estimated_at')
drop_table('sources_history')
a616581ee47_added_columns_to_table_requests.py 文件源码
项目:rucio
作者: rucio01
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def downgrade():
'''
downgrade method
'''
if context.get_context().dialect.name != 'sqlite':
drop_column('requests', 'bytes')
drop_column('requests', 'md5')
drop_column('requests', 'adler32')
drop_column('requests', 'dest_url')
drop_column('requests_history', 'bytes')
drop_column('requests_history', 'md5')
drop_column('requests_history', 'adler32')
drop_column('requests_history', 'dest_url')
def upgrade():
'''
upgrade method
'''
if context.get_context().dialect.name != 'sqlite':
add_column('requests', sa.Column('rule_id', GUID()))
add_column('requests_history', sa.Column('rule_id', GUID()))
def upgrade():
'''
upgrade method
'''
if context.get_context().dialect.name not in ('sqlite'):
# add purge replicas to dids/dids history
add_column('dids', sa.Column('purge_replicas',
sa.Boolean(name='DIDS_PURGE_REPLICAS_CHK'),
default=True))
add_column('dids', sa.Column('eol_at', sa.DateTime))
add_column('deleted_dids', sa.Column('purge_replicas',
sa.Boolean(name='DEL_DIDS_PURGE_RPLCS_CHK')))
add_column('deleted_dids', sa.Column('eol_at', sa.DateTime))
create_check_constraint('DIDS_PURGE_REPLICAS_NN', 'dids', 'purge_replicas is not null')
add_column('requests', sa.Column('account', sa.String(25)))
add_column('requests', sa.Column('requested_at', sa.DateTime))
add_column('requests', sa.Column('priority', sa.Integer))
create_foreign_key('REQUESTS_ACCOUNT_FK', 'requests', 'accounts', ['account'], ['account'])
add_column('requests_history', sa.Column('account', sa.String(25)))
add_column('requests_history', sa.Column('requested_at', sa.DateTime))
add_column('requests_history', sa.Column('priority', sa.Integer))
add_column('rules', sa.Column('priority', sa.Integer))
add_column('rules_hist_recent', sa.Column('priority', sa.Integer))
add_column('rules_history', sa.Column('priority', sa.Integer))
add_column('distances', sa.Column('active', sa.Integer))
add_column('distances', sa.Column('submitted', sa.Integer))
add_column('distances', sa.Column('finished', sa.Integer))
add_column('distances', sa.Column('failed', sa.Integer))
add_column('distances', sa.Column('transfer_speed', sa.Integer))