# Precondition: the following variables have to be correctly initialised
# * DB_SCHEMA_DIR set to the directory containing database initialisation and upgrade sql commands
# * DBSCRIPT_DEST_DIR set to the directory that will be populated with database upgrade scripts
# * DB_SCHEMA_DIR set to the directory containing database initialisation and upgrade sql commands
# * DBSCRIPT_DEST_DIR set to the directory that will be populated with database upgrade scripts
# * MAX_DB_VERSION_FOR_MIGRTION set to the max version number that should be used for generating migration scripts; further version will be managed by flyway
# Postcondition:
# * versions is set to the available MINERVA versions (bash array)
...
...
@@ -20,12 +21,22 @@ versions=();
current_version=-1;
#find all available versions
versionCompLte(){
["$1"="`echo-e"$1\n$2" | sort-V | head-n1`"]
}
versionCompLt(){
["$1"="$2"]&&return 1 || versionCompLte $1$2
}
for version in`ls"$DB_SCHEMA_DIR" | sort-V`;
do
if[-d"$DB_SCHEMA_DIR/$version"]
then
versions+=($version);
if versionCompLt $version$MAX_DB_VERSION_FOR_MIGRTION