¡@

Home 

OpenStack Study: 010_default_update_at.py

OpenStack Index

**** CubicPower OpenStack Study ****

def get_images_table(meta):

    """

    No changes to the images table from 008...

    """

    (get_images_table,) = from_migration_import(

        '008_add_image_members_table', ['get_images_table'])

    images = get_images_table(meta)

    return images

**** CubicPower OpenStack Study ****

def get_image_properties_table(meta):

    """

    No changes to the image properties table from 008...

    """

    (get_image_properties_table,) = from_migration_import(

        '008_add_image_members_table', ['get_image_properties_table'])

    image_properties = get_image_properties_table(meta)

    return image_properties

**** CubicPower OpenStack Study ****

def get_image_members_table(meta):

    """

    No changes to the image members table from 008...

    """

    (get_image_members_table,) = from_migration_import(

        '008_add_image_members_table', ['get_image_members_table'])

    images = get_image_members_table(meta)

    return images

**** CubicPower OpenStack Study ****

def upgrade(migrate_engine):

    meta = MetaData()

    meta.bind = migrate_engine

    images_table = get_images_table(meta)

    # set updated_at to created_at if equal to None

    conn = migrate_engine.connect()

    conn.execute(

        images_table.update(

            images_table.c.updated_at == None,

            {images_table.c.updated_at: images_table.c.created_at}))

**** CubicPower OpenStack Study ****

def downgrade(migrate_engine):

    meta = MetaData()

    meta.bind = migrate_engine

    images_table = get_images_table(meta)

    # set updated_at to None if equal to created_at

    conn = migrate_engine.connect()

    conn.execute(

        images_table.update(

            images_table.c.updated_at == images_table.c.created_at,

            {images_table.c.updated_at: None}))