From 7210e12656990922b7d2b499623152ff46317dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 21 Jun 2020 19:42:25 +0200 Subject: [PATCH] MAPG-162 add script that can run external SQLs on the DB --- scripts/run-sql.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 scripts/run-sql.sh diff --git a/scripts/run-sql.sh b/scripts/run-sql.sh new file mode 100755 index 0000000..80bf698 --- /dev/null +++ b/scripts/run-sql.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +if [ "$#" -lt 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +SQL_FILE=$1 + +ROOT_DIR=$(dirname $(readlink -f "$0"))/.. + +. ${ROOT_DIR}/.env + +if [ -z "${DEV}" ] || [ "${DEV}" -eq "0" ]; then + echo "This script can only be used in DEV mode!" + exit 1 +fi + +echo "Running SQL on DB..." +mysql --host=${DB_HOST} --user=${DB_USER} --password=${DB_PASSWORD} ${DB_NAME} < ${SQL_FILE}