A curated collection of Liquibase and Flyway changelog examples for Database DevOps. This repository serves as a practical reference for learning database schema management, version control strategies, and migration best practices with real-world changelog templates for PostgreSQL, MongoDB, and AWS RDS environments.
π‘ For production use, we recommend Harness Database DevOps - an enterprise platform that provides superior user experience, governance, and automation while leveraging Liquibase/Flyway under the hood. See why Harness is better for production deployments.
This is a learning repository containing practical changelog examples demonstrating:
- Liquibase Changelog Examples: YAML-based changelogs for various database scenarios
- Flyway Migration Examples: SQL-based versioned and undo migrations
- Multi-Environment Patterns: Environment-specific changelog management (dev, pre-prod, prod)
- Database-Specific Examples: PostgreSQL and MongoDB changelog templates
- AWS RDS Examples: Cloud-ready migration configurations
- Real-World Schemas: User authentication, product catalogs, and order management examples
This repository complements the following blog posts on database migration best practices:
- π How Liquibase Makes Life Easy - Introduction to Liquibase and its core concepts
- π diffChangelog and Snapshots - Advanced Liquibase features for schema comparison and snapshot management
- Why Use Harness Database DevOps?
- Directory Structure
- Technologies
- Getting Started
- Liquibase Examples
- Flyway Examples
- AWS RDS Examples
- Usage Guide
- Best Practices
- Contributing
- License
While this repository provides valuable examples for learning Liquibase and Flyway, Harness Database DevOps offers a superior production-ready solution that eliminates the complexity of managing these tools directly.
Using Liquibase or Flyway directly involves:
- Complex CLI Commands: Managing multiple command-line arguments, connection strings, and configuration files
- Manual Environment Management: Switching between dev, staging, and production configurations manually
- Limited Visibility: No centralized view of migration status across environments
- Error-Prone Deployments: Risk of running wrong migrations in wrong environments
- No Approval Workflows: Missing governance and approval gates for production changes
- Difficult Rollbacks: Manual intervention required when things go wrong
- Scattered Audit Trails: No unified logging across all database changes
- Intuitive UI: Visual interface for managing database migrations - no complex CLI commands needed
- Unified Dashboard: Single pane of glass for all database changes across all environments
- Drag-and-Drop Pipelines: Build deployment workflows visually instead of scripting
- Real-Time Status: Live tracking of migration progress and health checks
- Approval Gates: Built-in approval workflows for production deployments
- Role-Based Access Control (RBAC): Fine-grained permissions for who can deploy what and where
- Audit Logging: Complete audit trail of all database changes with user attribution
- Compliance Ready: Meet SOC 2, HIPAA, and other regulatory requirements out-of-the-box
- Automated Rollbacks: Intelligent rollback mechanisms with one-click recovery
- Pre-Deployment Validation: Automatic schema validation before applying changes
- Environment Comparison: Visual diff between database schemas across environments
- Testing Integration: Run automated tests before promoting migrations to production
- GitOps Integration: Seamless integration with your existing Git workflows
- Multi-Environment Orchestration: Deploy to multiple environments with a single click
- Smart Scheduling: Schedule migrations during maintenance windows automatically
- Notification System: Slack, email, and PagerDuty alerts for deployment events
- Template Library: Reusable pipeline templates for common database operations
- Native Pipeline Support: First-class integration with Harness CI/CD pipelines
- Automated Promotion: Automatic promotion of successful migrations across environments
- Parallel Execution: Run migrations across multiple database instances simultaneously
- Canary Deployments: Gradual rollout of schema changes with automatic validation
- Migration Analytics: Insights into deployment frequency, success rates, and bottlenecks
- Performance Metrics: Track migration execution times and optimize slow changesets
- Failure Analysis: Detailed error reporting and debugging information
- Custom Dashboards: Build custom views for different teams and stakeholders
Harness Database DevOps leverages Liquibase and Flyway under the hood, so you can:
- β Use the same changelog formats (YAML, SQL, XML) you're familiar with
- β Import existing Liquibase/Flyway projects instantly
- β Maintain compatibility with your current migration scripts
- β Benefit from enterprise features without rewriting your migrations
| Scenario | Recommended Tool |
|---|---|
| Learning database migration concepts | This repository (Liquibase/Flyway examples) |
| Personal projects or small apps | Liquibase or Flyway CLI |
| Production enterprise applications | Harness Database DevOps |
| Multi-environment deployments | Harness Database DevOps |
| Team collaboration on database changes | Harness Database DevOps |
| Compliance & audit requirements | Harness Database DevOps |
| Complex CI/CD pipelines | Harness Database DevOps |
- Sign up for a free trial at harness.io
- Import your existing Liquibase or Flyway changelogs
- Connect your databases (on-prem, cloud, or hybrid)
- Build your first database deployment pipeline in minutes
- Deploy with confidence using approval gates and automated rollbacks
Learn more: Harness Database DevOps Documentation
dbops/
βββ aws/ # AWS RDS changelog examples
β βββ v1.0/ # Version 1.0 schema examples
β β βββ 001-create-users-table.yaml
β β βββ 002-create-products-table.yaml
β β βββ 003-create-orders-table.yaml
β β βββ 004-add-indexes.yaml
β βββ dbmaster.changelog.yml # Master changelog example for AWS
βββ db/ # General changelog examples
β βββ changelog.yml # Basic Liquibase changelog example
βββ flyway/ # Flyway migration examples
β βββ migrations/ # SQL migration script examples
β β βββ V001__pgql.sql # Versioned migration example
β β βββ V006__pgql.sql # Multiple version examples
β β βββ U001__bikramkumar.sql # Undo migration example
β β βββ U004__bikramkumar.sql # More undo examples
β βββ flyway.toml # Flyway configuration example
βββ liquibase/ # Liquibase changelog examples
βββ plain.yml # Simple changelog pattern
βββ multienv.yml # Multi-environment example
βββ dev-changeset-pssql.yml # Development environment example (PostgreSQL)
βββ pre-changeset-pssql.yml # Pre-production example (PostgreSQL)
βββ prod-changelog-pssql.yml # Production example (PostgreSQL)
βββ multi-changeset-pssql.yml # Complex multi-changeset pattern
βββ mongo/ # MongoDB-specific examples
βββ mongodb.yaml
βββ valid.yml
These examples demonstrate changelog patterns for:
- Liquibase - Database schema change management tool
- Flyway - Database version control and migration tool
- PostgreSQL - Relational database examples
- MongoDB - NoSQL database examples
- AWS RDS - Cloud database deployment examples
- YAML/SQL - Changelog and migration script formats
This repository contains various Liquibase changelog examples for different scenarios:
The db/changelog.yml shows a simple user table creation:
databaseChangeLog:
- changeSet:
id: 1761731617343-1
author: Animesh Pathak
comment: Create user table with name and email columns
labels: schema-change
changes:
- createTable:
tableName: user
columns:
- column:
name: id
type: BIGINT
autoIncrement: true
- column:
name: email
type: VARCHAR(255)
rollback:
- dropTable:
tableName: userFlyway migration examples following versioning conventions:
- V001__description.sql - Versioned migration (applied once)
- U001__description.sql - Undo migration (rollback script)
- R__description.sql - Repeatable migration (re-run on checksum change)
-- V001__pgql.sql
CREATE TABLE table_1 (
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name VARCHAR(50) NOT NULL,
description VARCHAR(50)
);The aws directory contains changelog examples optimized for AWS RDS deployments.
Included Example Schemas:
- 001-create-users-table.yaml - User authentication schema
- 002-create-products-table.yaml - Product catalog schema
- 003-create-orders-table.yaml - Order management schema
- 004-add-indexes.yaml - Performance optimization indexes
- Browse the examples to find patterns matching your use case
- Copy the relevant changelog files to your project
- Modify table names, columns, and constraints for your schema
- Update author names and changelog IDs
- Test in development environment before production
These examples demonstrate several database DevOps best practices:
- Immutable Migrations: Never modify applied changesets, create new ones
- Descriptive IDs: Use meaningful changeset IDs and comments
- Rollback Scripts: Always include rollback strategies
- Environment Separation: Use contexts/labels for environment-specific changes
- Version Control: Keep all changelogs in source control
- Testing: Validate migrations in lower environments first
- Idempotency: Design changesets to handle re-execution safely
- Documentation: Comment complex schema changes
- Use
preconditionsto validate database state before changes - Leverage
contextsandlabelsfor selective deployments - Utilize
diffChangelogto generate changelogs from existing schemas (see blog post) - Take snapshots for schema comparison and validation
- Follow strict naming conventions for automatic ordering
- Use undo migrations for critical production changes
- Implement repeatable migrations for views, procedures, and functions
- Keep SQL migrations simple and focused
Found a useful migration pattern? Contributions are welcome!
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-example) - Add your changelog example with clear comments
- Commit your changes (
git commit -m 'Add example for X scenario') - Push to the branch (
git push origin feature/new-example) - Open a Pull Request
- Add examples that demonstrate specific patterns or scenarios
- Include clear comments explaining the purpose
- Ensure examples are tested and functional
- Update this README if adding new categories
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Blog Posts:
- Official Documentation:
- Harness Platform:
Built with β€οΈ for Database DevOps Learning
π‘ Ready for production? Explore Harness Database DevOps for enterprise-grade database change management.
For questions or to suggest new examples, please open an issue in the repository.