migration-check.sh 724 B

123456789101112131415
  1. #!/bin/bash
  2. # This script expects devservices to be running. It's main purpose is to check
  3. # that migrations and lockfiles are correct
  4. set -eu
  5. # This will fail if a migration or the lockfile are missing in the PR
  6. exit_code=0
  7. sentry django makemigrations --check --dry-run --no-input || exit_code=$?
  8. if [ "$exit_code" == 1 ]; then
  9. echo -e "::error::Error: Migration required -- to generate a migration, run:\n" \
  10. "sentry django makemigrations -n <some_name> && git add migrations_lockfile.txt" >&2
  11. elif [ "$exit_code" == 2 ]; then
  12. echo -e "::error::Error: Migration lockfile mismatch -- run:\n" \
  13. "sentry django makemigrations -n <some_name> && git add migrations_lockfile.txt" >&2
  14. fi
  15. exit $exit_code