A curated collection of Liquibase and Flyway changelog examples for Database DevOps, plus comprehensive Jenkins CI/CD pipelines demonstrating database governance implementation. This repository serves both as a learning resource and as a comparison showcase between traditional CI/CD approaches and modern database DevOps platforms.
🛠️ Pre-Installed Tools Approach - Production Jenkinsfiles use pre-installed Liquibase/Flyway on Jenkins agents. No Docker or wget/curl dependencies.
💡 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 detailed comparison.
Ready to test the Jenkins pipelines?
The production Jenkinsfiles (Jenkinsfile.liquibase and Jenkinsfile.flyway) use pre-installed tools on the Jenkins agent. This approach eliminates network dependencies and runtime downloads.
# SSH to your Jenkins agent, then run:
# Install Liquibase
wget https://github.com/liquibase/liquibase/releases/download/v4.24.0/liquibase-4.24.0.tar.gz
sudo mkdir -p /opt/liquibase
sudo tar -xzf liquibase-4.24.0.tar.gz -C /opt/liquibase
sudo ln -s /opt/liquibase/liquibase /usr/local/bin/liquibase
# Install PostgreSQL JDBC driver for Liquibase
wget https://jdbc.postgresql.org/download/postgresql-42.6.0.jar
sudo mv postgresql-42.6.0.jar /opt/liquibase/lib/
# Install Flyway (ARM64 version for Apple Silicon)
wget https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/10.4.1/flyway-commandline-10.4.1-linux-aarch64.tar.gz
sudo tar -xzf flyway-commandline-10.4.1-linux-aarch64.tar.gz -C /opt
sudo mv /opt/flyway-10.4.1 /opt/flyway
sudo ln -s /opt/flyway/flyway /usr/local/bin/flyway
# Install PostgreSQL JDBC driver for Flyway
sudo mkdir -p /opt/flyway/drivers
wget https://jdbc.postgresql.org/download/postgresql-42.6.0.jar
sudo mv postgresql-42.6.0.jar /opt/flyway/drivers/
# Verify installation
liquibase --version
flyway --version- Configure Jenkins pipeline job pointing to
Jenkinsfile.liquibaseorJenkinsfile.flyway - Build with parameters:
- ENVIRONMENT: dev
- DRY_RUN: true ✓
- Click "Build"
Benefits:
- ✅ No runtime downloads (tools already installed)
- ✅ No Docker dependencies
- ✅ Fast execution
- ✅ No network failures
- ✅ Works with standard Jenkins setup
Click to expand legacy approaches (not recommended)
# Uses wget/curl to download tools at runtime
# Update Jenkins job Script Path to:
# - Jenkinsfile.liquibase.local (for Liquibase)
# - Jenkinsfile.flyway.local (for Flyway)
# ⚠️ Warning: May fail with network issues (exit code 60)# Uses wget/curl to download tools at runtime
# Update Jenkins job Script Path to:
# - Jenkinsfile.liquibase.embedded (for Liquibase)
# - Jenkinsfile.flyway.embedded (for Flyway)
# ⚠️ Warning: May fail with network issues (exit code 60)| Metric | Jenkins + Flyway/Liquibase | Harness Database DevOps | Improvement |
|---|---|---|---|
| Setup Time | 2-3 days | 2-4 hours | 90% faster ⚡ |
| Lines of Code | 1,400+ | ~50 | 96% reduction 📉 |
| Custom Scripts | 300+ lines Python | 0 | 100% elimination ✨ |
| Governance Policies | Custom Python scripts | UI checkboxes | 95% faster 🚀 |
| Maintenance (hrs/month) | 40-66 hours | 3-8 hours | 85% reduction 💰 |
| Rollback | Manual scripts (15-30 min) | One-click (30 sec) | 97% faster ⚡ |
| Learning Curve | 7-10 weeks | 1-2 weeks | 80% easier 📚 |
| Annual TCO | $90,000-120,000 | $15,000-35,000 | 70% cheaper 💵 |
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.