Fix db migration 12

* fix bug 976908

Change-Id: I0248f825396d08688238e6d2ef37c8fcb49e8c9d
This commit is contained in:
Sam Morrison 2012-04-02 11:22:10 +10:00 committed by Brian Waldon
parent 8e9e0cadaf
commit 4e35808f94
2 changed files with 16 additions and 9 deletions

View File

@ -52,6 +52,7 @@ Rick Clark <rick@openstack.org>
Rick Harris <rconradharris@gmail.com> Rick Harris <rconradharris@gmail.com>
Reynolds Chin <benzwt@gmail.com> Reynolds Chin <benzwt@gmail.com>
Russell Bryant <rbryant@redhat.com> Russell Bryant <rbryant@redhat.com>
Sam Morrison <sorrison@gmail.com>
Soren Hansen <soren.hansen@rackspace.com> Soren Hansen <soren.hansen@rackspace.com>
Stuart McLaren <stuart.mclaren@hp.com> Stuart McLaren <stuart.mclaren@hp.com>
Taku Fukushima <tfukushima@dcl.info.waseda.ac.jp> Taku Fukushima <tfukushima@dcl.info.waseda.ac.jp>

View File

@ -225,18 +225,24 @@ def _get_table(table_name, metadata):
def _get_foreign_keys(t_images, t_image_members, t_image_properties): def _get_foreign_keys(t_images, t_image_members, t_image_properties):
"""Retrieve and return foreign keys for members/properties tables.""" """Retrieve and return foreign keys for members/properties tables."""
image_members_fk_name = list(t_image_members.foreign_keys)[0].name foreign_keys = []
image_properties_fk_name = list(t_image_properties.foreign_keys)[0].name if t_image_members.foreign_keys:
img_members_fk_name = list(t_image_members.foreign_keys)[0].name
fk1 = migrate.ForeignKeyConstraint([t_image_members.c.image_id], fk1 = migrate.ForeignKeyConstraint([t_image_members.c.image_id],
[t_images.c.id], [t_images.c.id],
name=image_members_fk_name) name=img_members_fk_name)
foreign_keys.append(fk1)
fk2 = migrate.ForeignKeyConstraint([t_image_properties.c.image_id], if t_image_properties.foreign_keys:
[t_images.c.id], img_properties_fk_name = list(t_image_properties.foreign_keys)[0].name
name=image_properties_fk_name)
return fk1, fk2 fk2 = migrate.ForeignKeyConstraint([t_image_properties.c.image_id],
[t_images.c.id],
name=img_properties_fk_name)
foreign_keys.append(fk2)
return foreign_keys
def _update_all_ids_to_uuids(t_images, t_image_members, t_image_properties): def _update_all_ids_to_uuids(t_images, t_image_members, t_image_properties):