39 / 65 · 15 SQL & Database Testing · Migration Testing← prev⊞ allnext →☰ Read as one page
5.7Migration Testing in CI
# GitHub Actions migration testing
migration-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: testpass
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Load production schema
run: psql -h localhost -U postgres -f schema_dump.sql
- name: Run migration
run: psql -h localhost -U postgres -f migrations/latest.sql
- name: Verify migration
run: pytest tests/migrations/ -v
- name: Test rollback
run: psql -h localhost -U postgres -f migrations/latest_rollback.sql