Update migration 076 so it supports PostgreSQL.
Fixes LP Bug #32154. Change-Id: I9d6ddfedcc39308811ff5264879b45b4847ec4a8
This commit is contained in:
1
.mailmap
1
.mailmap
@@ -19,6 +19,7 @@
|
|||||||
<dan@nicira.com> <danwent@dan-xs3-cs>
|
<dan@nicira.com> <danwent@dan-xs3-cs>
|
||||||
<dan@nicira.com> <danwent@gmail.com>
|
<dan@nicira.com> <danwent@gmail.com>
|
||||||
<devin.carlen@gmail.com> <devcamcar@illian.local>
|
<devin.carlen@gmail.com> <devcamcar@illian.local>
|
||||||
|
<dprince@redhat.com> <dan.prince@rackspace.com>
|
||||||
<edouard1.thuleau@orange.com> <thuleau@gmail.com>
|
<edouard1.thuleau@orange.com> <thuleau@gmail.com>
|
||||||
<ewan.mellor@citrix.com> <emellor@silver>
|
<ewan.mellor@citrix.com> <emellor@silver>
|
||||||
<ghe@debian.org> <ghe.rivero@gmail.com>
|
<ghe@debian.org> <ghe.rivero@gmail.com>
|
||||||
|
2
Authors
2
Authors
@@ -33,7 +33,7 @@ Chuck Short <zulcss@ubuntu.com>
|
|||||||
Cole Robinson <crobinso@redhat.com>
|
Cole Robinson <crobinso@redhat.com>
|
||||||
Cor Cornelisse <cor@hyves.nl>
|
Cor Cornelisse <cor@hyves.nl>
|
||||||
Cory Wright <corywright@gmail.com>
|
Cory Wright <corywright@gmail.com>
|
||||||
Dan Prince <dan.prince@rackspace.com>
|
Dan Prince <dprince@redhat.com>
|
||||||
Dan Wendlandt <dan@nicira.com>
|
Dan Wendlandt <dan@nicira.com>
|
||||||
Daniel P. Berrange <berrange@redhat.com>
|
Daniel P. Berrange <berrange@redhat.com>
|
||||||
Dave Lapsley <dlapsley@nicira.com>
|
Dave Lapsley <dlapsley@nicira.com>
|
||||||
|
@@ -21,46 +21,62 @@ from migrate.changeset.constraint import UniqueConstraint
|
|||||||
meta = MetaData()
|
meta = MetaData()
|
||||||
|
|
||||||
|
|
||||||
def upgrade(migrate_engine):
|
def _get_constraint_names(engine_name):
|
||||||
meta.bind = migrate_engine
|
|
||||||
table = Table('instance_types', meta, autoload=True)
|
|
||||||
# NOTE(vish): These constraint names may be dependent on the backend, but
|
# NOTE(vish): These constraint names may be dependent on the backend, but
|
||||||
# there doesn't seem to be we a way to determine the proper
|
# there doesn't seem to be we a way to determine the proper
|
||||||
# name for existing constraints. These names are correct for
|
# name for existing constraints. These names are correct for
|
||||||
# mysql.
|
# mysql and postgres.
|
||||||
|
if engine_name == "mysql":
|
||||||
|
return {
|
||||||
|
"instance_types_name": "name",
|
||||||
|
"instance_types_flavorid": "instance_types_flavorid_str_key",
|
||||||
|
"volume_types_name": "name",
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
"instance_types_name": "instance_types_name_key",
|
||||||
|
"instance_types_flavorid": "instance_types_flavorid_str_key",
|
||||||
|
"volume_types_name": "volume_types_name_key",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade(migrate_engine):
|
||||||
|
meta.bind = migrate_engine
|
||||||
|
c_names = _get_constraint_names(migrate_engine.name)
|
||||||
|
|
||||||
|
table = Table('instance_types', meta, autoload=True)
|
||||||
cons = UniqueConstraint('name',
|
cons = UniqueConstraint('name',
|
||||||
name='name',
|
name=c_names['instance_types_name'],
|
||||||
table=table)
|
table=table)
|
||||||
cons.drop()
|
cons.drop()
|
||||||
cons = UniqueConstraint('flavorid',
|
cons = UniqueConstraint('flavorid',
|
||||||
name='instance_types_flavorid_str_key',
|
name=c_names['instance_types_flavorid'],
|
||||||
table=table)
|
table=table)
|
||||||
cons.drop()
|
cons.drop()
|
||||||
table = Table('volume_types', meta, autoload=True)
|
table = Table('volume_types', meta, autoload=True)
|
||||||
cons = UniqueConstraint('name',
|
cons = UniqueConstraint('name',
|
||||||
name='name',
|
name=c_names['volume_types_name'],
|
||||||
table=table)
|
table=table)
|
||||||
cons.drop()
|
cons.drop()
|
||||||
|
|
||||||
|
|
||||||
def downgrade(migrate_engine):
|
def downgrade(migrate_engine):
|
||||||
meta.bind = migrate_engine
|
meta.bind = migrate_engine
|
||||||
|
c_names = _get_constraint_names(migrate_engine.name)
|
||||||
|
|
||||||
table = Table('instance_types', meta, autoload=True)
|
table = Table('instance_types', meta, autoload=True)
|
||||||
# NOTE(vish): These constraint names may be dependent on the backend, but
|
|
||||||
# there doesn't seem to be we a way to determine the proper
|
|
||||||
# name for existing constraints. These names are correct for
|
|
||||||
# mysql.
|
|
||||||
cons = UniqueConstraint('name',
|
cons = UniqueConstraint('name',
|
||||||
name='name',
|
name=c_names['instance_types_name'],
|
||||||
table=table)
|
table=table)
|
||||||
cons.create()
|
cons.create()
|
||||||
table = Table('instance_types', meta, autoload=True)
|
table = Table('instance_types', meta, autoload=True)
|
||||||
cons = UniqueConstraint('flavorid',
|
cons = UniqueConstraint('flavorid',
|
||||||
name='instance_types_flavorid_str_key',
|
name=c_names['instance_types_flavorid'],
|
||||||
table=table)
|
table=table)
|
||||||
cons.create()
|
cons.create()
|
||||||
table = Table('volume_types', meta, autoload=True)
|
table = Table('volume_types', meta, autoload=True)
|
||||||
cons = UniqueConstraint('name',
|
cons = UniqueConstraint('name',
|
||||||
name='name',
|
name=c_names['volume_types_name'],
|
||||||
table=table)
|
table=table)
|
||||||
cons.create()
|
cons.create()
|
||||||
|
Reference in New Issue
Block a user