Bug 2113 fix: POL upgrade from v10.1.1 to v12.0.0 fails due to changes in databases
Change-Id: I8907cc52383c4f860a0db751d1dd079df449f7bf
Signed-off-by: Guillermo Calvino <guillermo.calvino@canonical.com>
diff --git a/osm_policy_module/migrations/002_add_vnf_alarm.py b/osm_policy_module/migrations/002_add_vnf_alarm.py
index 65bf26b..5aa3660 100644
--- a/osm_policy_module/migrations/002_add_vnf_alarm.py
+++ b/osm_policy_module/migrations/002_add_vnf_alarm.py
@@ -60,10 +60,6 @@
nsr_id = pw.CharField(max_length=255)
vnf_member_index = pw.IntegerField()
vdu_name = pw.CharField(max_length=255)
- last_action = pw.CharField(max_length=255, default='insufficient-data')
- id_suffix = pw.IntegerField()
- ok_ack = pw.BooleanField(default=False)
- alarm_ack = pw.BooleanField(default=False)
class Meta:
table_name = "vnfalarm"
@@ -89,5 +85,4 @@
"""Write your rollback migrations here."""
migrator.remove_model("vnfalarm")
-
migrator.remove_model("alarmaction")
diff --git a/osm_policy_module/migrations/007_add_vnf_alarm_fields.py b/osm_policy_module/migrations/007_add_vnf_alarm_fields.py
new file mode 100644
index 0000000..185d5ef
--- /dev/null
+++ b/osm_policy_module/migrations/007_add_vnf_alarm_fields.py
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+
+# Copyright ETSI
+# *************************************************************
+
+# This file is part of OSM Monitoring module
+# All Rights Reserved to Whitestack, LLC
+
+# 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.
+
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: bdiaz@whitestack.com or glavado@whitestack.com
+##
+"""Peewee migrations -- 006_add_vnf_alarm_fields.py.
+
+Some examples (model - class or model name)::
+
+ > Model = migrator.orm['model_name'] # Return model in current state by name
+
+ > migrator.sql(sql) # Run custom SQL
+ > migrator.python(func, *args, **kwargs) # Run python code
+ > migrator.create_model(Model) # Create a model (could be used as decorator)
+ > migrator.remove_model(model, cascade=True) # Remove a model
+ > migrator.add_fields(model, **fields) # Add fields to a model
+ > migrator.change_fields(model, **fields) # Change fields
+ > migrator.remove_fields(model, *field_names, cascade=True)
+ > migrator.rename_field(model, old_field_name, new_field_name)
+ > migrator.rename_table(model, new_table_name)
+ > migrator.add_index(model, *col_names, unique=False)
+ > migrator.drop_index(model, *col_names)
+ > migrator.add_not_null(model, *field_names)
+ > migrator.drop_not_null(model, *field_names)
+ > migrator.add_default(model, field_name, default)
+
+"""
+
+import peewee as pw
+
+SQL = pw.SQL
+
+
+def migrate(migrator, database, fake=False, **kwargs):
+ """Write your migrations here."""
+
+ migrator.add_fields(
+ "vnfalarm",
+ last_action=pw.CharField(max_length=255, default="insufficient-data"),
+ ok_ack=pw.BooleanField(default=False),
+ id_suffix=pw.IntegerField(null=True),
+ alarm_ack=pw.BooleanField(default=False),
+ )
+
+
+def rollback(migrator, database, fake=False, **kwargs):
+ """Write your rollback migrations here."""
+
+ migrator.remove_fields(
+ "vnfalarm", "last_action", "id_suffix", "ok_ack", "alarm_ack"
+ )