**** CubicPower OpenStack Study ****
def define_tasks_table(meta):
tasks = Table('tasks',
meta,
Column('id', String(36), primary_key=True, nullable=False),
Column('type', String(30), nullable=False),
Column('status', String(30), nullable=False),
Column('owner', String(255), nullable=False),
Column('input', Text()), # json blob
Column('result', Text()), # json blob
Column('message', Text()),
Column('expires_at', DateTime(), nullable=True),
Column('created_at', DateTime(), nullable=False),
Column('updated_at', DateTime()),
Column('deleted_at', DateTime()),
Column('deleted',
Boolean(),
nullable=False,
default=False),
mysql_engine='InnoDB',
extend_existing=True)
Index('ix_tasks_type', tasks.c.type)
Index('ix_tasks_status', tasks.c.status)
Index('ix_tasks_owner', tasks.c.owner)
Index('ix_tasks_deleted', tasks.c.deleted)
Index('ix_tasks_updated_at', tasks.c.updated_at)
return tasks
**** CubicPower OpenStack Study ****
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
tables = [define_tasks_table(meta)]
create_tables(tables)
**** CubicPower OpenStack Study ****
def downgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
tables = [define_tasks_table(meta)]
drop_tables(tables)