Managing database schema changes across multiple environments is one of the most error-prone aspects of software development. Without a proper migration strategy, teams risk data loss, downtime, and inconsistent database states between development, staging, and production. This guide compares three leading open-source database migration tools — Bytebase, Flyway, and Liquibase — and shows you how to set each one up in a self-hosted environment.
Why Self-Host Your Database Migration Tool?
Database migration tools sit at the critical junction between your codebase and your data. Here is why running them on your own infrastructure matters:
- Schema security: Your database schema often reveals business logic, data relationships, and architectural decisions. Keeping migrations on your own servers prevents third-party exposure.
- Network access: Migration tools need direct connectivity to your databases. Self-hosting eliminates the need to open database ports to external SaaS platforms.
- Compliance: Industries like healthcare and finance require audit trails and data residency controls that only self-hosted solutions can guarantee.
- No vendor lock-in: Open-source migration tools store your schema history in plain files or your own database, giving you full ownership of the migration process.
- Cost predictability: Self-hosted solutions eliminate per-user or per-database licensing fees that scale unpredictably with team growth.
Overview: Three Approaches to Database Migrations
Each tool represents a different philosophy for managing schema changes.
Flyway takes the simplest approach: plain SQL migration files executed in order. It is lightweight, fast, and works with almost any SQL you can write. Flyway is ideal for teams that want minimal abstraction and maximum control over their SQL.
Liquibase uses declarative changelog files in XML, YAML, JSON, or SQL format. It abstracts database-specific SQL behind a common format, making it easier to support multiple database engines from a single changelog. Liquibase also offers rollback capabilities and detailed change tracking.
Bytebase goes beyond file-based migrations to provide a full database DevOps platform. It includes a web UI for reviewing and approving schema changes, built-in SQL review policies, environment management, and GitOps integration. Bytebase is designed for teams that need governance and collaboration around database changes.
Feature Comparison
| Feature | Flyway | Liquibase | Bytebase |
|---|---|---|---|
| Primary format | SQL files | XML/YAML/JSON/SQL | SQL + UI + GitOps |
| Web UI | No (Flyway Teams only) | No (Liquibase Pro only) | Yes (open-source) |
| Database support | 13+ databases | 14+ databases | 15+ databases |
| Rollback support | Community: limited | Full rollback tags | Built-in undo |
| SQL review | No | No | Yes (built-in) |
| Approval workflows | No | No | Yes |
| Environment management | Via config files | Via contexts/labels | Visual environment UI |
| GitOps integration | Via CI/CD scripts | Via CI/CD scripts | Native GitOps sync |
| Schema drift detection | No | Limited (Diff command) | Yes (continuous) |
| Audit log | Migration history table | Database changelog table | Full audit trail in UI |
| License | Apache 2.0 (core) | Apache 2.0 (core) | MIT |
| docker image | flyway/flyway | liquibase/liquibase | bytebase/bytebase |
Flyway: SQL-First Migrations
Installation via Docker
The quickest way to run Flyway is through its official Docker image:
| |
Docker Compose Setup
For a ppostgresqlready setup with PostgreSQL:
| |
Migration File Structure
Flyway migrations follow a strict naming convention: V<version>__<description>.sql
| |
Example migration file (V1__create_users_table.sql):
| |
Configuration
Create flyway.conf for reusable settings:
| |
CI/CD Integration
A GitHub Actions workflow for Flyway:
| |
When to Choose Flyway
- You prefer writing raw SQL and want zero abstraction overhead
- Your team works primarily with one database engine
- You need a lightweight tool that integrates easily into existing CI/CD pipelines
- Your migration workflow is linear (no complex branching or rollback needs)
Liquibase: Multi-Database Changelogs
Installation via Docker
| |
Docker Compose Setup
| |
Changelog Structure
Liquibase uses a master changelog that includes individual change files:
| |
Master changelog (changelog/main.yaml):
| |
Example Changeset (YAML format)
| |
Rollback Configuration
One of Liquibase’s strongest features is its rollback support:
| |
Liquibase Properties File
Create liquibase.properties for reusable configuration:
| |
Generate Diff from Existing Database
Liquibase can compare two databases and generate a changelog:
| |
When to Choose Liquibase
- Your application supports multiple database engines and you want a single changelog format
- You need reliable rollback capabilities for schema changes
- Your team prefers declarative changelog files over raw SQL
- You want to generate diffs between database states automatically
Bytebase: Database DevOps Platform
Installation via Docker
Bytebase provides a full web-based UI for managing database changes:
| |
Docker Compose with External PostgreSQL
For production, use an external PostgreSQL database for Bytebase’s own metadata:
| |
Setting Up Your First Project
After starting Bytebase, access the web UI at http://localhost:8080. The initial setup wizard will guide you through:
- Creating an admin account
- Adding your first database instance (PostgreSQL, MySQL, MongoDB, etc.)
- Creating a project and assigning environments (dev, staging, prod)
- Connecting a Git repository for GitOps-based migrations
GitOps Mode
Bytebase’s GitOps mode syncs SQL migration files from your Git repository to managed databases. Create a .bytebase configuration file at the root of your repository:
| |
Then organize your SQL files by environment:
| |
SQL Review Policies
Bytebase includes a built-in SQL review engine. You can configure policies such as:
| |
Approval Workflow
Bytebase supports multi-stage approval workflows for production changes:
- Developer creates a migration issue in the UI or pushes SQL to a Git branch
- The SQL review policy automatically validates the change
- A designated reviewer approves the migration
- Bytebase executes the migration during the approved maintenance window
- The audit log records who approved what, when, and the execution result
API Integration
Bytebase provides a REST API for automation:
| |
When to Choose Bytebase
- You need a visual interface for managing database changes across multiple teams
- SQL review and approval workflows are required for compliance
- You want GitOps integration with automatic sync from Git to databases
- Schema drift detection between environments is important
- You manage many databases and need centralized oversight
Choosing the Right Tool
| Scenario | Recommended Tool |
|---|---|
| Solo developer, simple SQL migrations | Flyway |
| Multi-database application with rollback needs | Liquibase |
| Team with compliance and governance requirements | Bytebase |
| CI/CD pipeline with minimal overhead | Flyway |
| Database-agnostic changelog management | Liquibase |
| Visual database administration and collaboration | Bytebase |
| GitOps-driven database changes | Bytebase |
| Fast migrations with zero runtime dependencies | Flyway |
| Automatic diff generation between databases | Liquibase |
Best Practices for Self-Hosted Database Migrations
Version Control Everything
Store all migration files in your version control system. Never apply ad-hoc SQL directly to production. Every schema change should have a corresponding migration file with a clear description.
Use Transactions for Migrations
Wrap your migration SQL in transactions when your database supports it. This ensures that failed migrations do not leave your schema in a partially applied state:
| |
Test Migrations Against a Copy of Production Data
Before running migrations in production, test them against a sanitized copy of your production database. This catches issues that unit tests might miss, such as data type incompatibilities or constraint violations.
Use Separate Migration Runs per Environment
Never share migration state between environments. Each environment should have its own migration history table and its own execution of the migration tool. This prevents a migration that works in development from failing silently in production.
Monitor Migration Execution Time
Large tables can make schema changes slow. Track how long each migration takes and set up alerts for migrations that exceed expected durations:
| |
Back Up Before Major Migrations
Always create a database backup before running destructive migrations:
| |
Conclusion
The choice between Bytebase, Flyway, and Liquibase comes down to your team’s workflow and governance needs. Flyway is the simplest option for teams comfortable writing raw SQL. Liquibase provides database-agnostic changelog management with strong rollback support. Bytebase offers a complete database DevOps platform with visual management, SQL review, and approval workflows.
All three tools can be self-hosted via Docker, giving you full control over your migration infrastructure. Start with the tool that matches your current complexity, and migrate to a more feature-rich option as your team and database estate grow.
Frequently Asked Questions (FAQ)
Which one should I choose in 2026?
The best choice depends on your specific requirements:
- For beginners: Start with the simplest option that covers your core use case
- For production: Choose the solution with the most active community and documentation
- For teams: Look for collaboration features and user management
- For privacy: Prefer fully open-source, self-hosted options with no telemetry
Refer to the comparison table above for detailed feature breakdowns.
Can I migrate between these tools?
Most tools support data import/export. Always:
- Backup your current data
- Test the migration on a staging environment
- Check official migration guides in the documentation
Are there free versions available?
All tools in this guide offer free, open-source editions. Some also provide paid plans with additional features, priority support, or managed hosting.
How do I get started?
- Review the comparison table to identify your requirements
- Visit the official documentation (links provided above)
- Start with a Docker Compose setup for easy testing
- Join the community forums for troubleshooting