From 97a50f61a99f4e96c3a2f537303853d956c1ff5e Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Wed, 5 Jul 2017 11:42:44 +0200 Subject: [PATCH] Fix (bug317): updated DB to change type of ram in flavors table Change-Id: I33b18e2c79347d79e01da875f49bdfeee2ca2836 Signed-off-by: garciadeblas --- database_utils/migrate_mano_db.sh | 16 +++++++++++++++- openmanod | 6 +++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/database_utils/migrate_mano_db.sh b/database_utils/migrate_mano_db.sh index d57194e0..5a96db7e 100755 --- a/database_utils/migrate_mano_db.sh +++ b/database_utils/migrate_mano_db.sh @@ -33,7 +33,7 @@ DBPORT="3306" DBNAME="mano_db" QUIET_MODE="" #TODO update it with the last database version -LAST_DB_VERSION=21 +LAST_DB_VERSION=22 # Detect paths MYSQL=$(which mysql) @@ -189,6 +189,7 @@ fi #[ $OPENMANO_VER_NUM -ge 5005 ] && DB_VERSION=19 #0.5.5 => 19 #[ $OPENMANO_VER_NUM -ge 5009 ] && DB_VERSION=20 #0.5.9 => 20 #[ $OPENMANO_VER_NUM -ge 5015 ] && DB_VERSION=21 #0.5.15 => 21 +#[ $OPENMANO_VER_NUM -ge 5016 ] && DB_VERSION=22 #0.5.16 => 22 #TODO ... put next versions here function upgrade_to_1(){ @@ -772,6 +773,19 @@ function downgrade_from_21(){ echo "DELETE FROM schema_version WHERE version_int='21';" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 } +function upgrade_to_22(){ + # echo " upgrade database from version 0.21 to version 0.22" + echo " Changed type of ram in 'flavors' from SMALLINT to MEDIUMINT" + echo "ALTER TABLE flavors CHANGE COLUMN ram ram MEDIUMINT(7) UNSIGNED NULL DEFAULT NULL AFTER disk;" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 + echo "INSERT INTO schema_version (version_int, version, openmano_ver, comments, date) VALUES (22, '0.22', '0.5.16', 'Changed type of ram in flavors from SMALLINT to MEDIUMINT', '2017-06-02');" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 +} +function downgrade_from_22(){ + # echo " downgrade database from version 0.22 to version 0.21" + echo " Changed type of ram in 'flavors' from MEDIUMINT to SMALLINT" + echo "ALTER TABLE flavors CHANGE COLUMN ram ram SMALLINT(5) UNSIGNED NULL DEFAULT NULL AFTER disk;" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 + echo "DELETE FROM schema_version WHERE version_int='22';" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 +} + function upgrade_to_X(){ echo " change 'datacenter_nets'" echo "ALTER TABLE datacenter_nets ADD COLUMN vim_tenant_id VARCHAR(36) NOT NULL AFTER datacenter_id, DROP INDEX name_datacenter_id, ADD UNIQUE INDEX name_datacenter_id (name, datacenter_id, vim_tenant_id);" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 diff --git a/openmanod b/openmanod index 8f8c3f1b..79f93bd8 100755 --- a/openmanod +++ b/openmanod @@ -48,9 +48,9 @@ import osm_ro __author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes" __date__ = "$26-aug-2014 11:09:29$" -__version__ = "0.5.15-r524" -version_date = "Jun 2017" -database_version = 21 #expected database schema version +__version__ = "0.5.16-r525" +version_date = "Jul 2017" +database_version = 22 #expected database schema version global global_config global logger -- 2.25.1