Flowsy.Cli.Db 1.0.0

dotnet tool install --global Flowsy.Cli.Db --version 1.0.0
                    
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 Flowsy.Cli.Db --version 1.0.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Flowsy.Cli.Db&version=1.0.0
                    
nuke :add-package Flowsy.Cli.Db --version 1.0.0
                    

FLowsy CLI for Database Management

Command-line tool for database management and migrations.

๐Ÿš€ Features

  • Database migrations with support for multiple providers (Postgres, MySQL, SQL Server, SQLite)
  • Built-in log viewer with advanced date filtering and search
  • Flexible configuration via JSON files or CLI arguments
  • Enhanced user interface with Spectre.Console
  • Localization in Spanish and English

๐Ÿ“ฆ Installation

dotnet tool install --global Flowsy.Cli.Db

๐Ÿ”ง Available Commands

migrate - Run Migrations

Runs database migrations using versioned scripts.

# Using a configuration file
flwdb migrate --config-file config.json

# Displays visual examples of valid migration folder structures, naming patterns, and ordering rules.
flwdb migrate example

# Using individual arguments
flwdb migrate \
  --provider Postgres \
  --connection "Host=localhost;Database=mydb;Username=user;Password=pass" \
  --source ./migrations

# With a base path for relative paths
flwdb migrate --config-file config.json --base-path /opt/app

# With multiple before and after scripts
flwdb migrate \
  --config-file config.json \
  --before "SET FOREIGN_KEY_CHECKS=0" \
  --before "@scripts/disable-triggers.sql" \
  --after "@scripts/enable-triggers.sql" \
  --after "SET FOREIGN_KEY_CHECKS=1"
Options
Option Alias Description
--config-file -cf JSON configuration file(s)
--config-section -cs Configuration file section
--provider -p DB provider (Postgres, MySql, SqlServer, Sqlite)
--connection -c Connection string
--source -s Directory containing migration scripts
--history-table -ht Migration history table
--history-schema -hs Migration history table schema
--before -b SQL script(s) or file(s) to run before (can be specified multiple times)
--after -a SQL script(s) or file(s) to run after (can be specified multiple times)
--out-of-order -oo Allow out-of-order migrations
--base-path -bp Base directory for relative paths
๐Ÿ“„ Configuration File

Example JSON configuration file:

{
  // ...
  "Databases": {
    // ...
    "MyPostgresDatabase": {
      "Provider": "Postgres",
      "ConnectionString": "Host=localhost;Port=5432;Database=mydb;Username=user;Password=pass",
      "BasePath": "/opt/app",
      "Migration": {
        "Source": "./migrations",
        "HistoryTable": "changelog",
        "HistorySchema": "public",
        "Scripts": {
          "Before": [
            "SQL Statement",
            "@/path/to/pre-migration-script-1.sql",
            "@/path/to/pre-migration-script-2.sql"
          ],
          "After": [
            "@/path/to/post-migration-script-1.sql",
            "SQL Statement",
            "@/path/to/post-migration-script-2.sql"
          ]
        },
        "OutOfOrder": false
      }
    }
    // ...
  }
  // ...
}

Note: To use the configuration in the previous example, you must pass --config-section with the value "Databases:MyPostgresDatabase".

Fields
  • Provider: Database provider (Postgres, MySql, SqlServer, Sqlite)
  • ConnectionString: Database connection string
  • Migration:Source: Directory containing migration scripts
  • Migration:BasePath: Base directory for resolving relative paths (optional)
  • Migration:HistoryTable: History table name (default: changelog)
  • Migration:HistorySchema: History table schema
  • Migration:Scripts:Before: Array of SQL scripts or files (with @ prefix) to run before migrations
  • Migration:Scripts:After: Array of SQL scripts or files (with @ prefix) to run after migrations
  • Migration:OutOfOrder: Specifies whether migrations can be applied out of order (true|false)
๐Ÿ“ Migration Structure

Scripts must follow the Evolve naming convention:

migrations/
โ”œโ”€โ”€ V001__create_schema.sql
โ”œโ”€โ”€ V002__create_users_table.sql
โ”œโ”€โ”€ V003__create_products_table.sql
โ”œโ”€โ”€ V004__add_indexes.sql
โ”œโ”€โ”€ R__create_views.sql
โ””โ”€โ”€ R__update_stored_procedures.sql

Versioned migrations (prefix V):

  • Run only once in sequential order
  • Version number (001, 002, 2026_01_001, 2026_01_002, etc.)
  • Double underscore __
  • Description in snake_case
  • .sql extension

Repeatable scripts (prefix R):

  • Run every time their checksum changes
  • No version number
  • Useful for views, stored procedures, and functions
  • Run after all versioned migrations

logs - View Logs

Displays and filters application logs with advanced options.

# Show log location and statistics
flwdb logs

# Show last 20 entries at info level
flwdb logs --level info

# List all available log files for a level
flwdb logs --level error --list-files

# Search for errors in the last 50 entries
flwdb logs -l error -t 50 -s "connection"

# Filter by date range
flwdb logs -l warning --from "2026-01-27" --to "2026-01-28"

# Use relative times (last hour)
flwdb logs -l info --from 1h

# Combine all filters
flwdb logs -l error --from 24h --to 1h --search "database" --tail 100
Options
Option Alias Description
--level -l Log level (debug, info, warning, error, fatal)
--tail -t Number of entries to display (default: 20)
--search -s Search text in messages
--from -f Date/time from (e.g. 2026-01-28, 1h, 30m, 2d)
--to Date/time to (same formats as --from)
--list-files -lf List all log files for the specified level

Relative time formats:

  • m - minutes (e.g. 30m = 30 minutes ago)
  • h - hours (e.g. 2h = 2 hours ago)
  • d - days (e.g. 7d = 7 days ago)
  • w - weeks (e.g. 1w = 1 week ago)

Logs are organized by level in subdirectories:

Logs/
โ”œโ”€โ”€ debug/
โ”‚   โ””โ”€โ”€ debug-2026012816.txt
โ”œโ”€โ”€ info/
โ”‚   โ””โ”€โ”€ info-2026012816.txt
โ”œโ”€โ”€ warning/
โ”‚   โ””โ”€โ”€ warning-2026012816.txt
โ”œโ”€โ”€ error/
โ”‚   โ””โ”€โ”€ error-2026012816.txt
โ””โ”€โ”€ fatal/
    โ””โ”€โ”€ fatal-2026012816.txt

Files rotate every hour and are stored in compact JSON format.

config - Configuration Management

config example - Show Example

Displays an example JSON configuration file.

flwdb config example
config providers - List Providers

Lists supported database providers.

flwdb config providers

๐Ÿงช Development

Requirements

  • .NET 10.0 SDK
  • Docker (optional, for integration tests)

Build

dotnet build

Run Tests

# Unit tests (without Docker)
dotnet test --filter "FullyQualifiedName~ConfigCommandTests|FullyQualifiedName~LogsCommandTests|FullyQualifiedName~MigrateCommandOptionsTests"

# Integration tests (requires Docker)
dotnet test

Publish

./publish.sh

๐Ÿ“š Additional Documentation

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.0.0 115 2/19/2026