capydb.cli
1.2.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet tool install --global capydb.cli --version 1.2.2
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local capydb.cli --version 1.2.2
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=capydb.cli&version=1.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package capydb.cli --version 1.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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:
./db/changelog/liquibase.properties(recommended)./liquibase.properties(root directory)./config/liquibase.properties./database/liquibase.properties./src/*/db/changelog/liquibase.properties(monorepos!)./apps/*/db/changelog/liquibase.properties(monorepos!)- 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
Recommended Project Structure
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
- π§ Email: evellynloraine@gmail.com
- πΌ LinkedIn: Evellyn Fernandes
- π± GitHub: lor4z
- π Documentation: CapyDb Docs
π License
This project is licensed under Apache 2.0.
π Useful Links
- NuGet Package: https://www.nuget.org/packages/capydb.cli/
- GitHub Repository: https://github.com/lor4z/capybara-db
- Current Version: 1.0.7
π 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 | Versions 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.