From f844c3f2fecf309a0c057f1da189942867c0b5e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <henrik@trineo.org> Date: Thu, 26 Mar 2020 12:43:52 +0100 Subject: [PATCH] MAINT: get working --- make_db | 8 +++----- makefile | 9 --------- patches/applyPatches.sh | 3 +-- patches/patch20151022-0/patch.sh | 2 +- update_sql_procedures.sh | 7 +++---- utils/backup.sh | 2 +- utils/helpers.sh | 16 ---------------- utils/patch_header.sh | 11 +++++++++++ 8 files changed, 20 insertions(+), 38 deletions(-) diff --git a/make_db b/make_db index daa82c7..d939586 100755 --- a/make_db +++ b/make_db @@ -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" } diff --git a/makefile b/makefile index 50b6858..ffc7896 100644 --- a/makefile +++ b/makefile @@ -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 diff --git a/patches/applyPatches.sh b/patches/applyPatches.sh index 0b1aced..2d4db68 100755 --- a/patches/applyPatches.sh +++ b/patches/applyPatches.sh @@ -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 diff --git a/patches/patch20151022-0/patch.sh b/patches/patch20151022-0/patch.sh index 43bc753..f361fb4 100755 --- a/patches/patch20151022-0/patch.sh +++ b/patches/patch20151022-0/patch.sh @@ -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" diff --git a/update_sql_procedures.sh b/update_sql_procedures.sh index a1cb42b..73f6bac 100755 --- a/update_sql_procedures.sh +++ b/update_sql_procedures.sh @@ -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" diff --git a/utils/backup.sh b/utils/backup.sh index 64455cf..22c1406 100755 --- a/utils/backup.sh +++ b/utils/backup.sh @@ -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 diff --git a/utils/helpers.sh b/utils/helpers.sh index af0ff03..b1f6d19 100644 --- a/utils/helpers.sh +++ b/utils/helpers.sh @@ -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 diff --git a/utils/patch_header.sh b/utils/patch_header.sh index 36a591f..7f85505 100644 --- a/utils/patch_header.sh +++ b/utils/patch_header.sh @@ -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 +} + + -- GitLab