¡@

Home 

OpenStack Study: 001_add_images_table.py

OpenStack Index

**** CubicPower OpenStack Study ****

def define_images_table(meta):

    images = Table('images',

                   meta,

                   Column('id', Integer(), primary_key=True, nullable=False),

                   Column('name', String(255)),

                   Column('type', String(30)),

                   Column('size', Integer()),

                   Column('status', String(30), nullable=False),

                   Column('is_public',

                          Boolean(),

                          nullable=False,

                          default=False,

                          index=True),

                   Column('location', Text()),

                   Column('created_at', DateTime(), nullable=False),

                   Column('updated_at', DateTime()),

                   Column('deleted_at', DateTime()),

                   Column('deleted',

                          Boolean(),

                          nullable=False,

                          default=False,

                          index=True),

                   mysql_engine='InnoDB',

                   extend_existing=True)

    return images

**** CubicPower OpenStack Study ****

def upgrade(migrate_engine):

    meta = MetaData()

    meta.bind = migrate_engine

    tables = [define_images_table(meta)]

    create_tables(tables)

**** CubicPower OpenStack Study ****

def downgrade(migrate_engine):

    meta = MetaData()

    meta.bind = migrate_engine

    tables = [define_images_table(meta)]

    drop_tables(tables)