@

Home 

OpenStack Study: 227_fix_project_user_quotas_resource_length.py

OpenStack Index

**** CubicPower OpenStack Study ****

def upgrade(migrate_engine):

    meta = MetaData(bind=migrate_engine)

    table = Table('project_user_quotas', meta, autoload=True)

    col_resource = getattr(table.c, 'resource')

    if col_resource.type.length == 25:

        # The resource of project_user_quotas table had been changed to

        # invalid length(25) since I56ad98d3702f53fe8cfa94093fea89074f7a5e90.

        # The following code fixes the length for the environments which are

        # deployed after I56ad98d3702f53fe8cfa94093fea89074f7a5e90.

        col_resource.alter(type=String(255))

        table.update().where(table.c.resource == 'injected_file_content_byt')\

            .values(resource='injected_file_content_bytes').execute()

**** CubicPower OpenStack Study ****

def downgrade(migrate_engine):

    # This migration fixes the resource of project_user_quotas table.

    # No need to go back and reverse this change.

    pass