symbiod/symbiod

View on GitHub
bin/test-migrations

Summary

Maintainability
Test Coverage
#!/bin/bash
# The goal of this script if to validate,
# if the migrations don't fail on production db and can be deployed safely.
# In order to do that we load the latest public dump into the travis database
# and apply schema and data migrations, to be sure that they don't fail.

# Here the database is recreated, since there can be existing tables after past operations
bundle exec rake db:drop && bundle exec rake db:create

bin/load_dump

# Run migrations and ensure that they do not fail
bundle exec rake db:migrate:with_data
exit_status=$?

# Cleanup the database
DISABLE_DATABASE_ENVIRONMENT_CHECK=1 bundle exec rake db:schema:load

# Always return the status of migration command
echo "The result is $exit_status"
exit $exit_status