You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_migrations.sh 977B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env bash
  2. #
  3. # Test migrations run correctly with MySQL and Postgres
  4. # Fail if any command fails
  5. # http://stackoverflow.com/questions/90418/exit-shell-script-based-on-process-exit-code
  6. set -e
  7. set -o pipefail
  8. if [ ! "$TRAVIS" == "true" ]
  9. then
  10. # If not on Travis, then create databases
  11. echo "Creating MySQL database and user"
  12. mysql -u root -e "DROP DATABASE IF EXISTS oscar_travis; CREATE DATABASE oscar_travis"
  13. mysql -u root -e "GRANT ALL PRIVILEGES ON oscar_travis.* TO 'travis'@'localhost' IDENTIFIED BY '';"
  14. echo "Creating Postgres database and user"
  15. psql -c "DROP ROLE IF EXISTS travis"
  16. psql -c "CREATE ROLE travis LOGIN PASSWORD ''"
  17. psql -c "DROP DATABASE IF EXISTS oscar_travis"
  18. psql -c "CREATE DATABASE oscar_travis"
  19. fi
  20. # MySQL
  21. echo "Running migrations against MySQL"
  22. ./manage.py migrate --noinput --settings=settings_mysql
  23. # Postgres
  24. echo "Running migrations against Postgres"
  25. ./manage.py migrate --noinput --settings=settings_postgres