mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Let job fail, when an error occurs during the legacy test script
This commit is contained in:
parent
19ae9e7456
commit
d766f255ef
1 changed files with 19 additions and 2 deletions
|
@ -24,14 +24,31 @@
|
|||
SQL_FILES_TO_TEST=("db_minimal.sql" "db_jbtronics.sql")
|
||||
|
||||
DB_NAME="test"
|
||||
DB_USER="root"
|
||||
DB_PASSWORD="root"
|
||||
|
||||
# Iterate over all given SQL files and import them into the mysql database with the given name, drop the database if it already exists before
|
||||
for SQL_FILE in "${SQL_FILES_TO_TEST[@]}"
|
||||
do
|
||||
echo "Testing for $SQL_FILE"
|
||||
mysql -u root -e "DROP DATABASE IF EXISTS $DB_NAME; CREATE DATABASE $DB_NAME;"
|
||||
mysql -u $DB_USER --password=$DB_PASSWORD -e "DROP DATABASE IF EXISTS $DB_NAME; CREATE DATABASE $DB_NAME;"
|
||||
# If the last command failed, exit the script
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to create database $DB_NAME"
|
||||
exit 1
|
||||
fi
|
||||
# Import the SQL file into the database. The file pathes are relative to the current script location
|
||||
mysql -u root $DB_NAME < .github/assets/legacy_import/$SQL_FILE
|
||||
mysql -u DB_USER --password=$DB_PASSWORD $DB_NAME < .github/assets/legacy_import/$SQL_FILE
|
||||
# If the last command failed, exit the script
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to import $SQL_FILE into database $DB_NAME"
|
||||
exit 1
|
||||
fi
|
||||
# Run doctrine migrations, this will migrate the database to the current version. This process should not fail
|
||||
php bin/console doctrine:migrations:migrate -n
|
||||
# If the last command failed, exit the script
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to migrate database $DB_NAME"
|
||||
exit 1
|
||||
fi
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue