**** CubicPower OpenStack Study ****
def upgrade(migrate_engine):
# Upgrade operations go here. Don't create your own engine; bind
# migrate_engine to your metadata
meta = sql.MetaData()
meta.bind = migrate_engine
consumer_table = sql.Table('consumer', meta, autoload=True)
request_token_table = sql.Table('request_token', meta, autoload=True)
access_token_table = sql.Table('access_token', meta, autoload=True)
constraints = [{'table': request_token_table,
'fk_column': 'consumer_id',
'ref_column': consumer_table.c.id},
{'table': access_token_table,
'fk_column': 'consumer_id',
'ref_column': consumer_table.c.id}]
if meta.bind != 'sqlite':
migration_helpers.add_constraints(constraints)
**** CubicPower OpenStack Study ****
def downgrade(migrate_engine):
meta = sql.MetaData()
meta.bind = migrate_engine
consumer_table = sql.Table('consumer', meta, autoload=True)
request_token_table = sql.Table('request_token', meta, autoload=True)
access_token_table = sql.Table('access_token', meta, autoload=True)
constraints = [{'table': request_token_table,
'fk_column': 'consumer_id',
'ref_column': consumer_table.c.id},
{'table': access_token_table,
'fk_column': 'consumer_id',
'ref_column': consumer_table.c.id}]
if meta.bind != 'sqlite':
migration_helpers.remove_constraints(constraints)