Adding cover to tox.ini default envs
[osm/RO.git] / RO / osm_ro / database_utils / migrate_mano_db.sh
index ab26ade..12f4566 100755 (executable)
@@ -35,8 +35,8 @@ DBNAME="mano_db"
 QUIET_MODE=""
 BACKUP_DIR=""
 BACKUP_FILE=""
-#TODO update it with the last database version
-LAST_DB_VERSION=40
+# TODO update it with the last database version
+LAST_DB_VERSION=42
 
 # Detect paths
 MYSQL=$(which mysql)
@@ -198,7 +198,9 @@ fi
 #[ $OPENMANO_VER_NUM -ge 6011 ] && DB_VERSION=38  #0.6.11 =>  38
 #[ $OPENMANO_VER_NUM -ge 6020 ] && DB_VERSION=39  #0.6.20 =>  39
 #[ $OPENMANO_VER_NUM -ge 6000004 ] && DB_VERSION=40  #6.0.4 =>  40
-#TODO ... put next versions here
+#[ $OPENMANO_VER_NUM -ge 8000000 ] && DB_VERSION=41  #8.0.0 =>  41
+#[ $OPENMANO_VER_NUM -ge 8000002 ] && DB_VERSION=42  #8.0.2 =>  42
+# TODO ... put next versions here
 
 function upgrade_to_1(){
     # echo "    upgrade database from version 0.0 to version 0.1"
@@ -1511,6 +1513,32 @@ function downgrade_from_40(){
     sql "DELETE FROM schema_version WHERE version_int='40';"
 }
 
+function upgrade_to_41(){
+    echo "      Removing unique name at 'wims' 'wim_accounts'"
+    sql "ALTER TABLE wims      DROP INDEX name;"
+    sql "ALTER TABLE wim_accounts      DROP INDEX wim_name;"
+    sql "INSERT INTO schema_version (version_int, version, openmano_ver, comments, date) " \
+        "VALUES (41, '0.41', '8.0.0', 'Removing unique name for wims/wim_accounts', '2020-07-16');"
+}
+function downgrade_from_41(){
+    echo "      Adding back unique name at 'wims' 'wim_accounts'"
+    sql "ALTER TABLE wims      ADD UNIQUE INDEX name (name);"
+    sql "ALTER TABLE wim_accounts      ADD UNIQUE INDEX wim_name (name);"
+    sql "DELETE FROM schema_version WHERE version_int='41';"
+}
+
+function upgrade_to_42(){
+    echo "      Adding 'port_security_disable_strategy' to 'interfaces'"
+    sql "ALTER TABLE interfaces    ADD COLUMN port_security_disable_strategy CHAR(25);"
+    sql "INSERT INTO schema_version (version_int, version, openmano_ver, comments, date) " \
+        "VALUES (42, '0.42', '8.0.2', 'Adding port_security_disable_strategy to interfaces', '2020-10-19');"
+}
+
+function downgrade_to_42(){
+    echo "      Removing 'port_security_disable_strategy' from 'interfaces'"
+    sql "ALTER TABLE interfaces     DROP port_security_disable_strategy;"
+    sql "DELETE FROM schema_version WHERE version_int='42';"
+}
 
 #TODO ... put functions here