Merged in feature/MAPG-162-add-script-that-can-run-sql-on-db (pull request #129)

MAPG-162 add script that can run external SQLs on the DB
This commit is contained in:
Bence Pőcze 2020-06-21 17:45:23 +00:00
commit 49bd03f303

20
scripts/run-sql.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
if [ "$#" -lt 1 ]; then
echo "Usage: $0 <sql_file>"
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}