

def downgrade(migrate_engine):
    meta = MetaData()
    meta.bind = migrate_engine
    conn = migrate_engine.connect()
    images = get_images_table(meta)
    image_properties = get_image_properties_table(meta)
    type_col = Column('type', String(30))
    type_col.create(images)
    sel = select([image_properties]).where((image_properties.c.key == 'type'))
    type_property_records = conn.execute(sel).fetchall()
    for record in type_property_records:
        upd = images.update().where((images.c.id == record.image_id)).values(type=record.value)
        conn.execute(upd)
        dlt = image_properties.delete().where((image_properties.c.image_id == record.image_id))
        conn.execute(dlt)
    conn.close()
    images.columns['disk_format'].drop()
    images.columns['container_format'].drop()

dataset/ETHPy150Open rcbops/glance-buildpackage/glance/registry/db/migrate_repo/versions/003_add_disk_format.py downgrade/original