# .github/workflows/migration-test.yml
name: Test Migration
on:
pull_request:
paths:
- 'migrations/**'
jobs:
test-migration:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Install Basecut CLI
run: |
curl -fsSL https://basecut.dev/install.sh | sh
echo "$HOME/.basecut/bin" >> $GITHUB_PATH
- name: Restore Pre-Migration Snapshot
env:
BASECUT_API_KEY: ${{ secrets.BASECUT_API_KEY }}
run: |
# Restore production-like data with OLD schema
basecut snapshot restore prod-schema:latest \
--target "postgresql://postgres:postgres@localhost:5432/postgres"
- name: Run Migration
run: |
npm run migrate
- name: Verify Migration Success
run: |
# Run tests against migrated schema
npm run test:integration
- name: Comment on PR
if: success()
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '✅ Migration tested successfully against production-like snapshot.'
})