chore(db_assembler): Changed var name (#1091)

- Added a missing "s" to the update suffix because it must match exactly the name of the updates/ directory (we have base, custom and updates)
- Also changed var name in config.sh.dist (edit your config.sh if you use it)
- Removed trailing spaces
This commit is contained in:
Barbz
2019-01-22 22:43:30 +01:00
committed by GitHub
parent 71e0ad005b
commit b41fd95874
2 changed files with 22 additions and 20 deletions

View File

@@ -4,7 +4,7 @@ PROMPT_PASS=""
# use in a subshell
function dbasm_resetExitCode() {
exit 0
exit 0
}
function dbasm_mysqlExec() {
@@ -13,12 +13,12 @@ function dbasm_mysqlExec() {
options=$3
eval $confs
if [[ ! -z "${PROMPT_USER// }" ]]; then
MYSQL_USER=$PROMPT_USER
MYSQL_PASS=$PROMPT_PASS
fi
export MYSQL_PWD=$MYSQL_PASS
retval=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" $options -e "$command")
@@ -51,7 +51,7 @@ function dbasm_mysqlExec() {
local _name="DB_"$_uc"_NAME"
local _dbname=${!_name}
eval $_confs
echo "Grant permissions for ${MYSQL_USER}'@'${MYSQL_HOST} to ${_dbname}"
"$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -e "GRANT ALL PRIVILEGES ON ${_dbname}.* TO '${MYSQL_USER}'@'${MYSQL_HOST}' WITH GRANT OPTION;"
@@ -65,7 +65,7 @@ function dbasm_mysqlExec() {
function dbasm_isNotEmpty() {
dbname=$1
conf=$2
dbasm_mysqlExec "$conf" "SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '${dbname}'" "--skip-column-names"
if (( $retval > 0 )); then
true
@@ -96,7 +96,7 @@ function dbasm_createDB() {
name="DB_"$uc"_NAME"
dbname=${!name}
eval $confs
CONF_USER=$MYSQL_USER
@@ -104,7 +104,7 @@ function dbasm_createDB() {
if dbasm_dbExists $dbname "$confs"; then
echo "$dbname database exists"
else
else
echo "Creating DB ${dbname} ..."
dbasm_mysqlExec "$confs" "CREATE DATABASE \`${dbname}\`" ""
dbasm_mysqlExec "$confs" "GRANT ALL PRIVILEGES ON \`${dbname}\`.* TO '${CONF_USER}'@'${MYSQL_HOST}' WITH GRANT OPTION;"
@@ -125,7 +125,7 @@ function dbasm_assemble() {
v="$name[@]"
base=("${!v}")
name="DB_"$uc"_UPDATE_PATHS"
name="DB_"$uc"_UPDATES_PATHS"
v="$name[@]"
updates=("${!v}")
@@ -135,7 +135,7 @@ function dbasm_assemble() {
suffix_base="_base"
suffix_upd="_update"
suffix_upd="_updates"
suffix_custom="_custom"
curTime=`date +%Y_%m_%d_%H_%M_%S`
@@ -242,7 +242,7 @@ function dbasm_db_backup() {
dbname=${!name}
eval $confs;
if [[ ! -z "${PROMPT_USER// }" ]]; then
MYSQL_USER=$PROMPT_USER
MYSQL_PASS=$PROMPT_PASS
@@ -291,7 +291,7 @@ function dbasm_db_import() {
echo "importing $1 - $2 ..."
eval $confs;
if [[ ! -z "${PROMPT_USER// }" ]]; then
MYSQL_USER=$PROMPT_USER
MYSQL_PASS=$PROMPT_PASS
@@ -299,10 +299,12 @@ function dbasm_db_import() {
export MYSQL_PWD=$MYSQL_PASS
# TODO: remove this line after we squash our DB updates
"$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" -e "SET GLOBAL max_allowed_packet=128*1024*1024;"
"$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" --default-character-set=utf8 "$dbname" < "${OUTPUT_FOLDER}${database}_${type}.sql"
if [[ $? -ne 0 ]]; then
err=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$MYSQL_USER" "$dbname" 2>&1 )
if [[ "$err" == *"Access denied"* ]]; then
@@ -355,21 +357,21 @@ function dbasm_import() {
do
dbasm_db_import "$db" "base"
done
fi
fi
if [ $with_updates = true ]; then
for db in ${DATABASES[@]}
do
dbasm_db_import "$db" "update"
dbasm_db_import "$db" "updates"
done
fi
fi
if [ $with_custom = true ]; then
for db in ${DATABASES[@]}
do
dbasm_db_import "$db" "custom"
done
fi
fi
echo "===== DONE ====="
}