diff --git a/nova/db/sqlalchemy/api_migrations/migrate_repo/versions/060_instance_group_policy_add_rules.py b/nova/db/sqlalchemy/api_migrations/migrate_repo/versions/060_instance_group_policy_add_rules.py new file mode 100644 index 0000000000..116432110d --- /dev/null +++ b/nova/db/sqlalchemy/api_migrations/migrate_repo/versions/060_instance_group_policy_add_rules.py @@ -0,0 +1,26 @@ +# 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 + + policies = Table('instance_group_policy', meta, autoload=True) + + if not hasattr(policies.c, 'rules'): + policies.create_column(Column('rules', Text)) diff --git a/nova/db/sqlalchemy/api_models.py b/nova/db/sqlalchemy/api_models.py index 56bd27d44a..8fed954a03 100644 --- a/nova/db/sqlalchemy/api_models.py +++ b/nova/db/sqlalchemy/api_models.py @@ -417,6 +417,7 @@ class InstanceGroupPolicy(API_BASE): policy = Column(String(255)) group_id = Column(Integer, ForeignKey('instance_groups.id'), nullable=False) + rules = Column(Text) class InstanceGroup(API_BASE): diff --git a/nova/tests/functional/db/api/test_migrations.py b/nova/tests/functional/db/api/test_migrations.py index 475cc4c2d7..1ad5efe377 100644 --- a/nova/tests/functional/db/api/test_migrations.py +++ b/nova/tests/functional/db/api/test_migrations.py @@ -713,6 +713,9 @@ class NovaAPIMigrationsWalk(test_migrations.WalkVersionsMixin): self.assertEqual(1, len(result)) self.assertEqual(0, result[0]['generation']) + def _check_060(self, engine, data): + self.assertColumnExists(engine, 'instance_group_policy', 'rules') + class TestNovaAPIMigrationsWalkSQLite(NovaAPIMigrationsWalk, test_base.DbTestCase,