diff --git a/nova/db/sqlalchemy/api_migrations/migrate_repo/versions/061_instance_mapping_add_queued_for_delete.py b/nova/db/sqlalchemy/api_migrations/migrate_repo/versions/061_instance_mapping_add_queued_for_delete.py new file mode 100644 index 0000000000..cedda1dbb0 --- /dev/null +++ b/nova/db/sqlalchemy/api_migrations/migrate_repo/versions/061_instance_mapping_add_queued_for_delete.py @@ -0,0 +1,27 @@ +# 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 Boolean +from sqlalchemy import Column +from sqlalchemy import MetaData +from sqlalchemy import Table + + +def upgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + instance_mappings = Table('instance_mappings', meta, autoload=True) + + if not hasattr(instance_mappings.c, 'queued_for_delete'): + instance_mappings.create_column(Column('queued_for_delete', Boolean, + default=False)) diff --git a/nova/db/sqlalchemy/api_models.py b/nova/db/sqlalchemy/api_models.py index 8fed954a03..1ac8b12091 100644 --- a/nova/db/sqlalchemy/api_models.py +++ b/nova/db/sqlalchemy/api_models.py @@ -138,6 +138,7 @@ class InstanceMapping(API_BASE): cell_id = Column(Integer, ForeignKey('cell_mappings.id'), nullable=True) project_id = Column(String(255), nullable=False) + queued_for_delete = Column(Boolean, default=False) cell_mapping = orm.relationship('CellMapping', backref=backref('instance_mapping', uselist=False), foreign_keys=cell_id, diff --git a/nova/tests/functional/db/api/test_migrations.py b/nova/tests/functional/db/api/test_migrations.py index 1ad5efe377..3e8c7530d9 100644 --- a/nova/tests/functional/db/api/test_migrations.py +++ b/nova/tests/functional/db/api/test_migrations.py @@ -716,6 +716,10 @@ class NovaAPIMigrationsWalk(test_migrations.WalkVersionsMixin): def _check_060(self, engine, data): self.assertColumnExists(engine, 'instance_group_policy', 'rules') + def _check_061(self, engine, data): + self.assertColumnExists(engine, 'instance_mappings', + 'queued_for_delete') + class TestNovaAPIMigrationsWalkSQLite(NovaAPIMigrationsWalk, test_base.DbTestCase,