-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Travis: Fix migrations and ensure failing
* Use correct username for MySQL on Travis Travis docs say username should be 'travis', not 'root'. * Fail test_migrations.sh if any command fails Previously, a failing (non-zero exit code) command would not lead to a non-zero exit code of test_migrations.sh. That meant that failing migrations would not fail the Travis job as intended.
- Loading branch information
1 parent
75ef01a
commit 104f97f
Showing
4 changed files
with
20 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ "$TRAVIS" == "true" ] | ||
# fail if any command fails | ||
# http://stackoverflow.com/questions/90418/exit-shell-script-based-on-process-exit-code | ||
set -e | ||
set -o pipefail | ||
|
||
if [ ! "$TRAVIS" == "true" ] | ||
then | ||
ROOT_PASSWORD="" | ||
else | ||
ROOT_PASSWORD="root_password" | ||
mysql -u root --password="root_password" -e "DROP DATABASE IF EXISTS oscar_vagrant; CREATE DATABASE oscar_vagrant" | ||
mysql -u root --password="root_password" -e "GRANT ALL PRIVILEGES ON oscar_vagrant.* TO 'travis'@'%' IDENTIFIED BY '';" | ||
|
||
sudo -u postgres psql -c "DROP ROLE IF EXISTS travis" | ||
sudo -u postgres psql -c "CREATE ROLE travis LOGIN PASSWORD ''" | ||
sudo -u postgres psql -c "DROP DATABASE IF EXISTS oscar_vagrant" | ||
sudo -u postgres psql -c "CREATE DATABASE oscar_vagrant" | ||
fi | ||
|
||
# MySQL | ||
mysql -u root --password=$ROOT_PASSWORD -e "DROP DATABASE IF EXISTS oscar_vagrant; CREATE DATABASE oscar_vagrant" | ||
mysql -u root --password=$ROOT_PASSWORD -e "GRANT ALL PRIVILEGES ON oscar_vagrant.* TO 'oscar_user'@'%' IDENTIFIED BY 'oscar_password';" | ||
./manage.py syncdb --noinput --settings=settings_mysql > /dev/null | ||
./manage.py migrate --noinput --settings=settings_mysql | ||
|
||
# Postgres | ||
sudo -u postgres psql -c "DROP DATABASE IF EXISTS oscar_vagrant" | ||
sudo -u postgres psql -c "CREATE DATABASE oscar_vagrant" | ||
sudo -u postgres psql -c "DROP ROLE IF EXISTS oscar_user" | ||
sudo -u postgres psql -c "CREATE ROLE oscar_user LOGIN PASSWORD 'oscar_password'" | ||
./manage.py syncdb --noinput --settings=settings_postgres > /dev/null | ||
./manage.py migrate --noinput --settings=settings_postgres |