Tools: Flyway, Liquibase, Sqitch
Compare popular schema migration tools, their versioning models, and CI integration.
Tools: Flyway, Liquibase, Sqitch is a free SQL Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the SQL Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why Migration Tools?
Schema changes need to be:
- Versioned in source control
- Applied in a deterministic order
- Run automatically in CI/CD
- Rollback-able (sometimes)
Flyway
Java-based, file-based migrations. Each file is named with a version prefix:
-- V1__create_users.sql
CREATE TABLE users (id BIGSERIAL PRIMARY KEY, email TEXT NOT NULL);
-- V2__add_full_name.sql
ALTER TABLE users ADD COLUMN full_name TEXT;
-- Flyway tracks applied migrations in a flyway_schema_history table.Flyway CLI
Apply migrations:
flyway -url=jdbc:postgresql://localhost/mydb -user=app migrate
flyway info # show what would run
flyway repair # fix the history table after a failureLiquibase
XML/YAML/JSON-based (or SQL) "changesets". More verbose than Flyway, but supports cross-database abstractions:
<!-- changeset alice:001 -->
<createTable tableName="users">
<column name="id" type="bigserial" autoIncrement="true">
<constraints primaryKey="true"/>
</column>
<column name="email" type="text"><constraints nullable="false"/></column>
</createTable>Liquibase Rollback Support
Each changeset can declare a rollback action. Liquibase can roll back the last N changes:
liquibase rollbackCount 1Sqitch
Native SQL, no version-number ordering — uses an explicit DAG of dependencies. Each change has deploy / verify / revert scripts:
sqitch add add_users -n 'Add users table'
# edits deploy/add_users.sql, verify/add_users.sql, revert/add_users.sql
sqitch deploy db:pg://localhost/mydbComparing the Three
| Flyway | Liquibase | Sqitch | |
|---|---|---|---|
| Format | SQL | XML/YAML/JSON | SQL |
| Versioning | Sequential | Sequential | DAG |
| Rollback | Limited | Native | Native |
| Verify step | No | Optional | Built-in |
Framework-Native Tools
Many web frameworks have their own:
- Rails: ActiveRecord migrations
- Django: built-in migrations
- Node: knex, sequelize, prisma migrate
- NestJS: TypeORM migrations
CI Workflow
Standard pipeline:
- PR includes new migration file
- CI spins up an empty Postgres, runs all migrations
- Run automated tests against the migrated schema
- On merge, deploy + run migrations against staging, then production
Repeatable Migrations
Flyway has "R__" repeatable migrations — re-run on every change. Good for views, stored procs:
-- R__users_view.sql (re-applied whenever its checksum changes)
CREATE OR REPLACE VIEW active_users AS
SELECT id, email FROM users WHERE deleted_at IS NULL;Schema Drift Detection
Use migra, schemahero, or pgquarrel to detect drift between expected and actual schema.
Recap
Pick a tool, stick with it.
- Flyway — SQL-first, simple
- Liquibase — declarative, abstraction layers
- Sqitch — DAG dependencies, rollback-first
- Always: version in source control, automate in CI
Quick Check
Which tool natively uses an explicit DAG of dependencies between migrations instead of sequential version numbers?
Frequently asked questions
Is the “Tools: Flyway, Liquibase, Sqitch” lesson free?
Yes — the full text of “Tools: Flyway, Liquibase, Sqitch” is free to read here on the web, and the SQL Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the SQL Academy course, upgrade to CoddyKit PRO.
What will I learn in “Tools: Flyway, Liquibase, Sqitch”?
Compare popular schema migration tools, their versioning models, and CI integration. You practise SQL Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start SQL Academy?
No prior experience is required. SQL Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Tools: Flyway, Liquibase, Sqitch” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this SQL Academy lesson?
Yes. Every SQL Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Online Migrations: Why ALTER TABLE Locks
- Concurrent Indexes (CREATE INDEX CONCURRENTLY)
- Zero-Downtime Column Renames
- Tools: Flyway, Liquibase, Sqitch