refcodes-batch.0.3.0.source-code.create-db.job Maven / Gradle / Ivy
#!/bin/bash
if [[ $HELP = y ]] ; then
echo "The switch \"-j $JOB\" uses a given configuration to create a given " >&2
echo "DB. The DB is created according to the specified CHARACTER SET and COLLATE " >&2
echo "config. Use this SQL on your DB to find out the CHARACTER SET and COLLATE " >&2
echo "config: " >&2
echo "+ \"SHOW VARIABLES LIKE 'character_set_database';\" " >&2
echo "+ \"SHOW VARIABLES LIKE 'collation_database';\" " >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
fi
. $SCRIPT_DIR/validate-db-config.job
if [[ $HELP = y ]] ; then
exit $EXIT_SUCCESS
fi
exitOnConfigOff "DB"
if [[ $VERBOSE = y ]] ; then
echo "Creating DB \"$DB_NAME\" with CHARACTER SET \"$DB_CHARACTER_SET\" and COLLATE \"$DB_COLLATE\" ..." >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
fi
# mysql -u$DB_USER_NAME -p$DB_USER_PASSWORD --execute="CREATE DATABASE IF NOT EXISTS \`$DB_NAME\` CHARACTER SET $DB_CHARACTER_SET COLLATE $DB_COLLATE;"
mysql -u$DB_USER_NAME -p$DB_USER_PASSWORD --execute="CREATE DATABASE \`$DB_NAME\` CHARACTER SET $DB_CHARACTER_SET COLLATE $DB_COLLATE;"
exitOnError "Unable to create DB \"$DB_NAME\" !!!"
echo " DB \"$DB_NAME\" was created:" >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
echo "+ DB details see: \"$DB_NAME@$DB_HOSTNAME\"" >&2
echo "+ DB CHARACTER SET: \"$DB_CHARACTER_SET\"" >&2
echo "+ DB COLLATE: \"$DB_COLLATE\"" >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
showSuccess "DB \"$DB_NAME\" created !"