DBNAME="vim_db"
QUIET_MODE=""
#TODO update it with the last database version
-LAST_DB_VERSION=21
+LAST_DB_VERSION=22
# Detect paths
MYSQL=$(which mysql)
#[ $OPENVIM_VER_NUM -ge 5015 ] && DATABASE_TARGET_VER_NUM=19 #0.5.15 => 19
#[ $OPENVIM_VER_NUM -ge 5017 ] && DATABASE_TARGET_VER_NUM=20 #0.5.17 => 20
#[ $OPENVIM_VER_NUM -ge 5018 ] && DATABASE_TARGET_VER_NUM=21 #0.5.18 => 21
+#[ $OPENVIM_VER_NUM -ge 5021 ] && DATABASE_TARGET_VER_NUM=22 #0.5.21 => 22
# TODO ... put next versions here
function upgrade_to_1(){
echo "DELETE FROM schema_version WHERE version_int = '21';" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
}
+function upgrade_to_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, openvim_ver, comments, date) VALUES (22, '0.22', '0.5.21', 'Changed type of ram in flavors from SMALLINT to MEDIUMINT', '2017-11-14');"\
+ | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
+}
+
+function downgrade_from_22(){
+ 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
+}
+
#TODO ... put funtions here
__author__ = "Alfonso Tierno, Leonardo Mirabal"
__date__ = "$06-Feb-2017 12:07:15$"
-__version__ = "0.5.20-r536"
-version_date = "Sep 2017"
-database_version = 21 #needed database schema version
+__version__ = "0.5.21-r537"
+version_date = "Nov 2017"
+database_version = 22 #needed database schema version
HTTP_Bad_Request = 400
HTTP_Unauthorized = 401