Skip to content
Snippets Groups Projects
Commit f844c3f2 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: get working

parent caef918c
Branches
Tags
No related merge requests found
......@@ -32,8 +32,6 @@ fi
source $UTILSPATH/load_settings.sh
source $UTILSPATH/helpers.sh
INSTALL_SQL_FILE="db_2_0.sql"
set -e
function fail() {
......@@ -201,9 +199,9 @@ EOF
# The first argument to this function is the database that shal be dropped.
function drop() {
DROPDB="$1"
#for host in ${DATABASE_USER_HOST_LIST//,/ } ; do
#$MYSQL_CMD $(get_mysql_args_nodb) -e "DROP USER '${DATABASE_USER}'@'${host}';" || true
#done
for host in ${DATABASE_USER_HOST_LIST//,/ } ; do
$MYSQL_CMD $(get_mysql_args_nodb) -e "DROP USER '${DATABASE_USER}'@'${host}';" || true
done
"$MYSQLADMIN_CMD" $(get_mysql_args_nodb) -f drop "$DROPDB"
}
......
......@@ -24,15 +24,6 @@ SHELL=/bin/bash
INSTALL_SQL_FILE=db_2_0.sql
# TODO can this be removed?
#ifdef LOGIN_PATH
# M_MYSQL_CONNECTION=--login-path=$(M_LOGIN_PATH)
#else
# MYSQL_CONNECTION=--host="$(MYSQL_HOST)" --port="$(MYSQL_PORT)" \
# --user="$(MYSQL_USER)" --password="$(MYSQL_USER_PASSWORD)"
#endif
.PHONY: test-connection
test-connection:
./make_db test-connection
......
......@@ -25,10 +25,9 @@
#
#apply all available patches.
set -e
PATCHES="./patch*/patch.sh"
. $UTILSPATH/helpers.sh
set -e
for p in $PATCHES
do
$p "$@" --patch=$p
......
......@@ -35,7 +35,7 @@ fi
check_version $OLD_VERSION
function addIdx {
$MYSQL_CMD $(get_con_args) -e "ALTER TABLE $1 ADD COLUMN pidx TINYINT UNSIGNED NOT NULL DEFAULT 0;"
$MYSQL_CMD $(get_db_args) -e "ALTER TABLE $1 ADD COLUMN pidx TINYINT UNSIGNED NOT NULL DEFAULT 0;"
}
addIdx "reference_data"
......
......@@ -24,17 +24,16 @@
# Updates all SQL procedures
. utils/load_settings.sh
. utils/helpers.sh
source $UTILSPATH/helpers.sh
echo -n "updating rules ... "
set -e
mysql_execute "$(sed s/db_2_0/$DATABASE_NAME/g rules.sql)"
success
echo "OK"
echo -n "updating procedures ... "
mysql_execute "$(sed s/db_2_0/$DATABASE_NAME/g procedures/*.sql procedures/query/*.sql)"
success
echo "OK"
......@@ -75,7 +75,7 @@ function backup() {
failure "dumpfile already exists."
fi
echo "Dumping database $NARG_NAME to $NARG_FILE ... "
$MYSQLDUMP_CMD $(get_con_args_no_db) $* --opt --default-character-set=utf8 --routines \
$MYSQLDUMP_CMD $(get_mysql_args_no_db) $* --opt --default-character-set=utf8 --routines \
"$NARG_NAME" > "$NARG_FILE"
if [[ "$YAML" == "true" ]] ; then
......
......@@ -18,10 +18,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
function dump_table {
$MYSQLDUMP_CMD $(get_db_args_nodb) $DATABASE_NAME $1 \
> ${DATABASE_NAME}.${1}.${OLD_VERSION}.dump.sql
}
function mysql_execute {
#TODO is it meaningful that here always the database user is used???
......@@ -35,18 +31,10 @@ function mysql_execute {
}
function get_mysql_args {
# if [ "$DATABASE_NAME" = "caosdb" ];then
# echo "WRONGDB"
# exit 1
# fi
echo "$(get_mysql_args_nodb) --database=$DATABASE_NAME"
}
function get_db_args {
# if [ "$DATABASE_NAME" = "caosdb" ];then
# echo "WRONGDB"
# exit 1
# fi
echo "$(get_db_args_nodb) --database=$DATABASE_NAME"
}
......@@ -86,10 +74,6 @@ function get_mysql_args_nodb {
echo $mysql_con_arguments
}
function redo_table {
$MYSQL_CMD $(get_db_args) < ${DATABASE_NAME}.${1}.${OLD_VERSION}.dump.sql
}
function success {
echo "[OK]"
exit 0
......
......@@ -121,3 +121,14 @@ function check_version {
function update_version {
mysql_execute "DROP FUNCTION IF EXISTS CaosDBVersion; CREATE FUNCTION CaosDBVersion() RETURNS VARCHAR(255) DETERMINISTIC RETURN '$1';"
}
function dump_table {
$MYSQLDUMP_CMD $(get_db_args_nodb) $DATABASE_NAME $1 \
> ${DATABASE_NAME}.${1}.${OLD_VERSION}.dump.sql
}
function redo_table {
$MYSQL_CMD $(get_db_args) < ${DATABASE_NAME}.${1}.${OLD_VERSION}.dump.sql
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment