diff --git a/scripts/build-db.sh b/scripts/build-db.sh index 837dd86..79b40fb 100644 --- a/scripts/build-db.sh +++ b/scripts/build-db.sh @@ -20,6 +20,9 @@ if [ ! $2 ];then exit 1 fi +# Log paths +migration_logs=sql-migration.log + migration_loc=$1 env_path=$2 @@ -49,17 +52,20 @@ if [ ! $DATABASE_PORT ];then fi # Next we setup the database user -mysql -e "CREATE USER '$DATABASE_USER'@'$DATABASE_HOST' IDENTIFIED BY '$DATABASE_PASS';" +mysql -e "CREATE USER '$DATABASE_USER'@'$DATABASE_HOST' IDENTIFIED BY '$DATABASE_PASS';" \ + > $migration_logs 2>&1 # Yet another reason to not use this in prod to setup you're database -mysql -e "GRANT ALL PRIVILEGES ON *.* TO '$DATABASE_USER'@'$DATABASE_HOST';" +mysql -e "GRANT ALL PRIVILEGES ON *.* TO '$DATABASE_USER'@'$DATABASE_HOST';" \ + >> $migration_logs 2>&1 # First we'll setup the databse that we want to use for dir in $(ls $migration_loc);do # Port field is ignored in this script as its straight up not used in Docker tests - echo Migrating $dir - mysql -u $DATABASE_USER -p $DATABASE_PASS \ + # NOTE: there should **not** be a space between -p and the database password + echo Migrating $migration_loc/$dir + mysql -u $DATABASE_USER -p$DATABASE_PASS \ -h $DATABASE_HOST -D $DATABASE_NAME \ - < $dir/up.sql + < $migration_loc/$dir/up.sql >> $migration_logs 2>&1 done