capydb.cli 1.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global capydb.cli --version 1.2.1
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local capydb.cli --version 1.2.1
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=capydb.cli&version=1.2.1
                    
nuke :add-package capydb.cli --version 1.2.1
                    

CapyDb CLI

A command-line tool for managing database migrations with Liquibase and Entity Framework Core.

πŸš€ What is CapyDb?

CapyDb CLI addresses the challenge of managing database migrations consistently and efficiently, offering:

  • βœ… Automatic configuration detection - automatically searches for liquibase.properties
  • βœ… Migration creation in Liquibase YAML format
  • βœ… Migration import from Entity Framework Core
  • βœ… Schema merge and consolidation automation
  • βœ… Safe execution with SQL execution plans
  • βœ… Multi-DBMS support (SQL Server, PostgreSQL, MySQL, Oracle)
  • βœ… Docker integration and CI/CD pipelines
  • βœ… Drift detection - identifies undocumented changes
  • βœ… Tag system - create and remove tags for versioning
  • βœ… Smart rollback - revert by count or to a specific tag
  • βœ… History squash - consolidates old migrations
  • βœ… Automatic author detection via Git/CI/CD
  • βœ… Comprehensive diagnostics with cap doctor
  • βœ… Changelog validation before execution
  • βœ… INSERTs converter - converts SQL INSERTs to Liquibase format

πŸ“¦ Installation

Prerequisites

  • .NET 8.0 SDK or higher
  • Java 8+ (for Liquibase)

Global Installation

# Install via NuGet
dotnet tool install -g capydb.cli

# Verify installation
cap --version  # 1.0.7

🏁 Getting Started

1. Set Up Project

# Recommended structure
my-project/
β”œβ”€β”€ db/
β”‚   └── changelog/
β”‚       β”œβ”€β”€ common/
β”‚       β”œβ”€β”€ db.changelog-master.yaml
β”‚       └── liquibase.properties  # ← CLI auto-detects this!
β”œβ”€β”€ src/
└── Infrastructure/  # Or any project structure

2. Check Prerequisites

cap doctor

3. Create First Migration

# Create a basic migration
cap migrations add create-users

# With specific author
cap migrations add create-products --author "Your Name"

4. Import from Entity Framework

cap migrations import-ef \
  --assembly ./MyApp.dll \
  --name CreateUsersTable \
  --provider sqlserver

5. Run Migrations (Auto-Detection!)

# CLI automatically searches in ./db/changelog/liquibase.properties
cap plan      # Generate execution plan
cap apply     # Apply migrations
cap status    # Check database status

# Create tag after deployment
cap tag v1.0.0

# Rollback if needed
cap rollback count 2
cap rollback to-tag v1.0.0

πŸ’‘ Automatic Configuration Detection (Enhanced!)

The CLI now features robust recursive search for liquibase.properties:

Search Priority:

  1. ./db/changelog/liquibase.properties (recommended)
  2. ./liquibase.properties (root directory)
  3. ./config/liquibase.properties
  4. ./database/liquibase.properties
  5. ./src/*/db/changelog/liquibase.properties (monorepos!)
  6. ./apps/*/db/changelog/liquibase.properties (monorepos!)
  7. Recursive search in all subdirectories (excluding node_modules, .git)

Works perfectly on Windows, Linux, and macOS!

# Before (still works):
cap apply --defaults ./db/changelog/liquibase.properties

# Now (even simpler):
cap apply  # Auto-detects in monorepos, nested structures, anywhere!

πŸ“‹ Quick Examples

my-project/
β”œβ”€β”€ db/
β”‚   β”œβ”€β”€ changelog/
β”‚   β”‚   β”œβ”€β”€ common/
β”‚   β”‚   β”‚   └── 20250924_120000__create-users.yaml
β”‚   β”‚   β”œβ”€β”€ db.changelog-master.yaml
β”‚   β”‚   └── liquibase.properties  # ← Auto-detected!
β”‚   └── drivers/
└── src/

Auto-Generated Migration

# db/changelog/common/20250924_120000__create-users.yaml
databaseChangeLog:
  - changeSet:
      id: 20250924_120000-create-users
      author: MoisΓ©s Drumand  # ← Detected via Git!
      context: common
      changes:
        - createTable:
            tableName: users
            columns:
              - column:
                  name: id
                  type: int
                  constraints:
                    primaryKey: true

Simplified Full Workflow

# 1. Create migration
cap migrations add create-users

# 2. Review what will be executed
cap plan

# 3. Apply to database
cap apply

# 4. Check status
cap status

# 5. Create version tag
cap tag v1.0.0

# 6. Revert if needed
cap rollback to-tag v1.0.0

Multiple Environments and DBMS

# Default environment (auto-detected)
cap apply

# PostgreSQL with custom file
cap apply --defaults ./db/changelog/liquibase-postgres.properties

# MySQL with Docker
cap apply --defaults ./db/changelog/liquibase-mysql.properties --docker

# Oracle
cap apply --defaults ./db/changelog/liquibase-oracle.properties

Converting SQL INSERTs

# Convert SQL INSERTs file to Liquibase format
cap convert-inserts --input ./data.sql --output ./changelog.yaml

# Specify table name
cap convert-inserts --input ./data.sql --table users --output ./changelog.yaml

πŸ§ͺ Tests

The project includes automated integration tests using Jest and Prisma.

# Run integration tests
cd tests/integration
npm install
npm test

# Tests with different DBMS
npm test -- --testMatch="**/migration.test.ts"

πŸ“š Documentation

For complete documentation, visit: Documentation

πŸ”§ Main Commands

Command Description
cap doctor Check prerequisites and connectivity
cap migrations add <name> Create new migration with auto-detected author
cap migrations import-ef Import migrations from EF Core
cap migrations mergeschemas Consolidate multiple migrations
cap plan Generate SQL execution plan
cap apply Apply migrations to database
cap status View database status and pending migrations
cap validate Validate changelog syntax
cap drift detect Detect undocumented changes
cap tag <name> Create tag for versioning
cap remove-tag <tag> Remove existing tag
cap rollback count <N> Revert N migrations
cap rollback to-tag <tag> Revert to a specific tag
cap squash --tag <tag> Consolidate history up to a tag
cap bye Farewell with ASCII art 🦫

πŸ’¬ Contact

πŸ“„ License

This project is licensed under Apache 2.0.

πŸ†• What's New in v1.0.7

  • βœ… Enhanced file search on Windows - Fixed glob pattern issues
  • βœ… Robust recursive search - Finds liquibase.properties anywhere
  • βœ… Monorepo support - Works with complex project structures
  • βœ… Improved assembly detection - Better EF Core integration
  • βœ… Cross-platform compatibility - Tested on Windows, Linux, macOS

Developed with ❀️ to simplify database migration management.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.2.3 232 10/28/2025
1.2.2 199 10/16/2025
1.2.1 207 10/14/2025