Use for any question or task about Flyway, including errors such as a checksum mismatch, a failed validate or an edited old migration: versioned, repeatable and undo migration files, migrate, info, validate, baseline and repair, the schema history table, migration ordering, and CI gates on schema changes, via CLI, Maven, Gradle or Docker.
94%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Per fw-home, Flyway's commands are Migrate, Clean, Info, Validate, Undo, Baseline, Repair, Check, and Snapshot.
| Command | Use |
|---|---|
flyway migrate | Apply pending migrations |
flyway info | Show applied + pending migration list |
flyway validate | Verify checksums of applied migrations vs disk files |
flyway baseline | Mark a legacy schema state as baseline (skip prior migrations) |
flyway repair | Fix a broken flyway_schema_history (e.g., after a failed migration) |
flyway undo | Roll back the last versioned migration (Teams) |
flyway clean | Drop all objects in the schema (production-disabled by default) |
Pattern: ephemeral DB (Docker / Testcontainers) per PR, apply migrations, run tests against the migrated schema.
- name: Spin up Postgres
uses: docker/setup-buildx-action@v3
- run: docker run -d --name pg -p 5432:5432 -e POSTGRES_PASSWORD="$FLYWAY_PASSWORD" postgres:16
env:
FLYWAY_PASSWORD: ${{ secrets.CI_DB_PASSWORD }}
- name: Apply migrations
env:
FLYWAY_PASSWORD: ${{ secrets.CI_DB_PASSWORD }}
run: |
docker run --rm --network=host -e FLYWAY_PASSWORD \
-v "$PWD/db/migration:/flyway/sql" \
flyway/flyway -url=jdbc:postgresql://localhost:5432/postgres \
-user=postgres migrate
- name: Run tests
run: mvn testBoth steps read the password from the CI_DB_PASSWORD repository secret,
so no literal value lands in the workflow file.
For full integration with testcontainers (in the qa-test-environment
plugin): spin up the DB via Testcontainers, then call Flyway.configure()
in JUnit @BeforeAll.