Merge "apidb: Compact Pike database migrations"
This commit is contained in:
commit
5f4b1ae269
|
@ -1,23 +0,0 @@
|
|||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# This is a placeholder for backports.
|
||||
# Do not use this number for new work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
|
@ -1,66 +0,0 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
"""Database migrations for traits"""
|
||||
|
||||
from migrate.changeset.constraint import ForeignKeyConstraint
|
||||
from migrate import UniqueConstraint
|
||||
from sqlalchemy import Column
|
||||
from sqlalchemy import DateTime
|
||||
from sqlalchemy import ForeignKey
|
||||
from sqlalchemy import Index
|
||||
from sqlalchemy import Integer
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy import Table
|
||||
from sqlalchemy import Unicode
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
if migrate_engine.name == 'mysql':
|
||||
nameargs = {'collation': 'utf8_bin'}
|
||||
else:
|
||||
nameargs = {}
|
||||
|
||||
resource_providers = Table('resource_providers', meta, autoload=True)
|
||||
|
||||
traits = Table(
|
||||
'traits', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('id', Integer, primary_key=True, nullable=False,
|
||||
autoincrement=True),
|
||||
Column('name', Unicode(255, **nameargs), nullable=False),
|
||||
UniqueConstraint('name', name='uniq_traits0name'),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='latin1'
|
||||
)
|
||||
|
||||
resource_provider_traits = Table(
|
||||
'resource_provider_traits', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('trait_id', Integer, ForeignKey('traits.id'), primary_key=True,
|
||||
nullable=False),
|
||||
Column('resource_provider_id', Integer, primary_key=True,
|
||||
nullable=False),
|
||||
Index('resource_provider_traits_resource_provider_trait_idx',
|
||||
'resource_provider_id', 'trait_id'),
|
||||
ForeignKeyConstraint(columns=['resource_provider_id'],
|
||||
refcolumns=[resource_providers.c.id]),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='latin1'
|
||||
)
|
||||
|
||||
for table in [traits, resource_provider_traits]:
|
||||
table.create(checkfirst=True)
|
|
@ -1,26 +0,0 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sqlalchemy import Column
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy import Table
|
||||
from sqlalchemy import Text
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
build_requests = Table('build_requests', meta, autoload=True)
|
||||
|
||||
if not hasattr(build_requests.c, 'tags'):
|
||||
build_requests.create_column(Column('tags', Text()))
|
|
@ -1,44 +0,0 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
"""Database migrations for consumers"""
|
||||
|
||||
from migrate import UniqueConstraint
|
||||
from sqlalchemy import Column
|
||||
from sqlalchemy import DateTime
|
||||
from sqlalchemy import Index
|
||||
from sqlalchemy import Integer
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy import String
|
||||
from sqlalchemy import Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
consumers = Table('consumers', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('id', Integer, primary_key=True, nullable=False,
|
||||
autoincrement=True),
|
||||
Column('uuid', String(length=36), nullable=False),
|
||||
Column('project_id', String(length=255), nullable=False),
|
||||
Column('user_id', String(length=255), nullable=False),
|
||||
Index('consumers_project_id_uuid_idx', 'project_id', 'uuid'),
|
||||
Index('consumers_project_id_user_id_uuid_idx', 'project_id', 'user_id',
|
||||
'uuid'),
|
||||
UniqueConstraint('uuid', name='uniq_consumers0uuid'),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='latin1'
|
||||
)
|
||||
|
||||
consumers.create(checkfirst=True)
|
|
@ -176,6 +176,7 @@ def upgrade(migrate_engine):
|
|||
Column('instance_uuid', String(length=36)),
|
||||
Column('instance', MediumText()),
|
||||
Column('block_device_mappings', MediumText()),
|
||||
Column('tags', Text()),
|
||||
UniqueConstraint(
|
||||
'instance_uuid', name='uniq_build_requests0instance_uuid'),
|
||||
Index('build_requests_project_id_idx', 'project_id'),
|
||||
|
@ -201,6 +202,30 @@ def upgrade(migrate_engine):
|
|||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
projects = Table('projects', meta,
|
||||
Column(
|
||||
'id', Integer, primary_key=True, nullable=False,
|
||||
autoincrement=True),
|
||||
Column('external_id', String(length=255), nullable=False),
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
UniqueConstraint('external_id', name='uniq_projects0external_id'),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='latin1',
|
||||
)
|
||||
|
||||
users = Table('users', meta,
|
||||
Column(
|
||||
'id', Integer, primary_key=True, nullable=False,
|
||||
autoincrement=True),
|
||||
Column('external_id', String(length=255), nullable=False),
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
UniqueConstraint('external_id', name='uniq_users0external_id'),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='latin1',
|
||||
)
|
||||
|
||||
resource_classes = Table('resource_classes', meta,
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('name', String(length=255), nullable=False),
|
||||
|
@ -259,6 +284,19 @@ def upgrade(migrate_engine):
|
|||
mysql_charset='latin1'
|
||||
)
|
||||
|
||||
traits = Table(
|
||||
'traits', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column(
|
||||
'id', Integer, primary_key=True, nullable=False,
|
||||
autoincrement=True),
|
||||
Column('name', Unicode(255, **nameargs), nullable=False),
|
||||
UniqueConstraint('name', name='uniq_traits0name'),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='latin1',
|
||||
)
|
||||
|
||||
allocations = Table(
|
||||
'allocations', meta,
|
||||
Column('created_at', DateTime),
|
||||
|
@ -278,6 +316,25 @@ def upgrade(migrate_engine):
|
|||
mysql_charset='latin1'
|
||||
)
|
||||
|
||||
consumers = Table(
|
||||
'consumers', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column(
|
||||
'id', Integer, primary_key=True, nullable=False,
|
||||
autoincrement=True),
|
||||
Column('uuid', String(length=36), nullable=False),
|
||||
Column('project_id', Integer, nullable=False),
|
||||
Column('user_id', Integer, nullable=False),
|
||||
Index('consumers_project_id_uuid_idx', 'project_id', 'uuid'),
|
||||
Index(
|
||||
'consumers_project_id_user_id_uuid_idx', 'project_id', 'user_id',
|
||||
'uuid'),
|
||||
UniqueConstraint('uuid', name='uniq_consumers0uuid'),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='latin1',
|
||||
)
|
||||
|
||||
resource_provider_aggregates = Table(
|
||||
'resource_provider_aggregates', meta,
|
||||
Column('created_at', DateTime),
|
||||
|
@ -291,6 +348,25 @@ def upgrade(migrate_engine):
|
|||
mysql_charset='latin1'
|
||||
)
|
||||
|
||||
resource_provider_traits = Table(
|
||||
'resource_provider_traits', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column(
|
||||
'trait_id', Integer, ForeignKey('traits.id'), primary_key=True,
|
||||
nullable=False),
|
||||
Column(
|
||||
'resource_provider_id', Integer, primary_key=True, nullable=False),
|
||||
Index(
|
||||
'resource_provider_traits_resource_provider_trait_idx',
|
||||
'resource_provider_id', 'trait_id'),
|
||||
ForeignKeyConstraint(
|
||||
columns=['resource_provider_id'],
|
||||
refcolumns=[resource_providers.c.id]),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='latin1',
|
||||
)
|
||||
|
||||
placement_aggregates = Table('placement_aggregates', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
|
@ -476,11 +552,16 @@ def upgrade(migrate_engine):
|
|||
request_specs,
|
||||
build_requests,
|
||||
keypairs,
|
||||
projects,
|
||||
users,
|
||||
resource_classes,
|
||||
resource_providers,
|
||||
inventories,
|
||||
traits,
|
||||
allocations,
|
||||
consumers,
|
||||
resource_provider_aggregates,
|
||||
resource_provider_traits,
|
||||
placement_aggregates,
|
||||
aggregates,
|
||||
aggregate_hosts,
|
|
@ -1,72 +0,0 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Streamlines consumers table and adds projects and users table"""
|
||||
|
||||
from migrate import UniqueConstraint
|
||||
from sqlalchemy import Column
|
||||
from sqlalchemy import DateTime
|
||||
from sqlalchemy import Integer
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy import String
|
||||
from sqlalchemy import Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
projects = Table('projects', meta,
|
||||
Column('id', Integer, primary_key=True, nullable=False,
|
||||
autoincrement=True),
|
||||
Column('external_id', String(length=255), nullable=False),
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
UniqueConstraint('external_id', name='uniq_projects0external_id'),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='latin1'
|
||||
)
|
||||
|
||||
projects.create(checkfirst=True)
|
||||
|
||||
users = Table('users', meta,
|
||||
Column('id', Integer, primary_key=True, nullable=False,
|
||||
autoincrement=True),
|
||||
Column('external_id', String(length=255), nullable=False),
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
UniqueConstraint('external_id', name='uniq_users0external_id'),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='latin1'
|
||||
)
|
||||
|
||||
users.create(checkfirst=True)
|
||||
|
||||
consumers = Table('consumers', meta, autoload=True)
|
||||
project_id_col = consumers.c.project_id
|
||||
user_id_col = consumers.c.user_id
|
||||
|
||||
# NOTE(jaypipes): For PostgreSQL, we can't do col.alter(type=Integer)
|
||||
# because NVARCHAR and INTEGER are not compatible, so we need to do this
|
||||
# manual ALTER TABLE ... USING approach.
|
||||
if migrate_engine.name == 'postgresql':
|
||||
migrate_engine.execute(
|
||||
"ALTER TABLE consumers ALTER COLUMN project_id "
|
||||
"TYPE INTEGER USING project_id::integer"
|
||||
)
|
||||
migrate_engine.execute(
|
||||
"ALTER TABLE consumers ALTER COLUMN user_id "
|
||||
"TYPE INTEGER USING user_id::integer"
|
||||
)
|
||||
else:
|
||||
project_id_col.alter(type=Integer)
|
||||
user_id_col.alter(type=Integer)
|
|
@ -29,7 +29,7 @@ from nova.i18n import _
|
|||
|
||||
INIT_VERSION = {}
|
||||
INIT_VERSION['main'] = 401
|
||||
INIT_VERSION['api'] = 29
|
||||
INIT_VERSION['api'] = 43
|
||||
_REPOSITORY = {}
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
|
@ -172,7 +172,6 @@ class NovaAPIMigrationsWalk(test_migrations.WalkVersionsMixin):
|
|||
return self.engine
|
||||
|
||||
def _skippable_migrations(self):
|
||||
ocata_placeholders = list(range(31, 41))
|
||||
pike_placeholders = list(range(45, 50))
|
||||
queens_placeholders = list(range(53, 58))
|
||||
# We forgot to add the rocky placeholders
|
||||
|
@ -183,8 +182,7 @@ class NovaAPIMigrationsWalk(test_migrations.WalkVersionsMixin):
|
|||
special_cases = [
|
||||
self.INIT_VERSION + 1, # initial change
|
||||
]
|
||||
return (ocata_placeholders +
|
||||
pike_placeholders +
|
||||
return (pike_placeholders +
|
||||
queens_placeholders +
|
||||
stein_placeholders +
|
||||
train_placeholders +
|
||||
|
@ -223,64 +221,6 @@ class NovaAPIMigrationsWalk(test_migrations.WalkVersionsMixin):
|
|||
self.assertRaises(sqlalchemy.exc.NoSuchTableError,
|
||||
db_utils.get_table, engine, table_name)
|
||||
|
||||
def _check_041(self, engine, data):
|
||||
self.assertColumnExists(engine, 'traits', 'id')
|
||||
self.assertUniqueConstraintExists(engine, 'traits', ['name'])
|
||||
|
||||
self.assertColumnExists(engine, 'resource_provider_traits', 'trait_id')
|
||||
self.assertColumnExists(engine, 'resource_provider_traits',
|
||||
'resource_provider_id')
|
||||
self.assertIndexExists(
|
||||
engine, 'resource_provider_traits',
|
||||
'resource_provider_traits_resource_provider_trait_idx')
|
||||
|
||||
inspector = reflection.Inspector.from_engine(engine)
|
||||
self.assertEqual(
|
||||
2, len(inspector.get_foreign_keys('resource_provider_traits')))
|
||||
for fk in inspector.get_foreign_keys('resource_provider_traits'):
|
||||
if 'traits' == fk['referred_table']:
|
||||
self.assertEqual(['id'], fk['referred_columns'])
|
||||
self.assertEqual(['trait_id'], fk['constrained_columns'])
|
||||
elif 'resource_providers' == fk['referred_table']:
|
||||
self.assertEqual(['id'], fk['referred_columns'])
|
||||
self.assertEqual(['resource_provider_id'],
|
||||
fk['constrained_columns'])
|
||||
|
||||
def _check_042(self, engine, data):
|
||||
self.assertColumnExists(engine, 'build_requests', 'tags')
|
||||
|
||||
def _check_043(self, engine, data):
|
||||
for column in ['created_at', 'updated_at', 'id', 'uuid', 'project_id',
|
||||
'user_id']:
|
||||
self.assertColumnExists(engine, 'consumers', column)
|
||||
|
||||
self.assertIndexExists(engine, 'consumers',
|
||||
'consumers_project_id_uuid_idx')
|
||||
self.assertIndexExists(engine, 'consumers',
|
||||
'consumers_project_id_user_id_uuid_idx')
|
||||
self.assertUniqueConstraintExists(engine, 'consumers', ['uuid'])
|
||||
|
||||
def _check_044(self, engine, data):
|
||||
for column in ['created_at', 'updated_at', 'id', 'external_id']:
|
||||
self.assertColumnExists(engine, 'projects', column)
|
||||
self.assertColumnExists(engine, 'users', column)
|
||||
|
||||
self.assertUniqueConstraintExists(engine, 'projects', ['external_id'])
|
||||
self.assertUniqueConstraintExists(engine, 'users', ['external_id'])
|
||||
|
||||
# We needed to drop and recreate columns and indexes on consumers, so
|
||||
# check that worked out properly
|
||||
self.assertColumnExists(engine, 'consumers', 'project_id')
|
||||
self.assertColumnExists(engine, 'consumers', 'user_id')
|
||||
self.assertIndexExists(
|
||||
engine, 'consumers',
|
||||
'consumers_project_id_uuid_idx',
|
||||
)
|
||||
self.assertIndexExists(
|
||||
engine, 'consumers',
|
||||
'consumers_project_id_user_id_uuid_idx',
|
||||
)
|
||||
|
||||
def _check_050(self, engine, data):
|
||||
self.assertColumnExists(engine, 'flavors', 'description')
|
||||
|
||||
|
|
Loading…
Reference in New Issue