migration-check.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. name: Migration check
  2. # A deploy migrates the database while the previous version may still be
  3. # serving, and a rollback runs the previous version against the new schema.
  4. # Both work only while a migration leaves the old code working, so this fails
  5. # a pull request whose new migrations drop, rename, retype or tighten
  6. # something (see .github/scripts/check-migrations.mjs). When such a change is
  7. # safe anyway, add the allow-breaking-migration label and say why in the
  8. # description; the label reruns this check.
  9. on:
  10. pull_request:
  11. branches: [main]
  12. types: [opened, synchronize, reopened, labeled, unlabeled]
  13. paths: ["prisma/migrations/**"]
  14. concurrency:
  15. group: migration-check-${{ github.ref }}
  16. cancel-in-progress: true
  17. jobs:
  18. check:
  19. name: Migrations keep the running version working
  20. runs-on: ubuntu-latest
  21. timeout-minutes: 5
  22. steps:
  23. # The merge commit and its first parent, the base branch as it is now.
  24. - uses: actions/checkout@v4
  25. with:
  26. fetch-depth: 2
  27. - name: Check new and changed migrations
  28. if: ${{ !contains(github.event.pull_request.labels.*.name, 'allow-breaking-migration') }}
  29. run: |
  30. mapfile -t files < <(git diff --name-only --diff-filter=AM HEAD^1 HEAD -- 'prisma/migrations/*/migration.sql')
  31. node .github/scripts/check-migrations.mjs "${files[@]}"
  32. - name: Allowed by label
  33. if: ${{ contains(github.event.pull_request.labels.*.name, 'allow-breaking-migration') }}
  34. run: echo "::notice title=Migration check skipped::The allow-breaking-migration label is on this pull request."