This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test database migration and rollback | |
on: | |
push: | |
branches: | |
- 'main' | |
- 'fix-env-services-drop-index' | |
paths: | |
- 'services/api/database/**' | |
tags: | |
- 'v*.*.*' | |
pull_request: | |
branches: | |
- 'main' | |
paths: | |
- 'services/api/database/**' | |
jobs: | |
makeup: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout PR | |
uses: actions/checkout@v4 | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
fetch-depth: "0" | |
ref: ${{ github.event.pull_request.head.sha }} | |
- | |
name: Checkout Branch or Tag | |
uses: actions/checkout@v4 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
fetch-depth: "0" | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Bring up a docker compose lagoon | |
id: make_up | |
run: | | |
make build | |
make up | |
- | |
name: Show initial migration logs | |
run: | | |
docker compose -p lagoon logs api-init | |
- | |
name: Initiate rollback | |
run: | | |
docker compose -p lagoon exec api sh -c './node_modules/.bin/knex migrate:rollback --all --cwd /app/services/api/database' | |
- | |
name: Reperform initial migration | |
run: | | |
docker compose -p lagoon exec api sh -c './node_modules/.bin/knex migrate:latest --cwd /app/services/api/database' | |
- | |
name: Remove testing setup | |
run: | | |
make down |