ditto

command module
v0.0.0-...-14535a3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 3 Imported by: 0

README ΒΆ

ditto

Go Version License CI Go Report Card

πŸ”„ A powerful CLI tool for database synchronization between PostgreSQL and MySQL

ditto demo

✨ Features

  • Schema Comparison - Compare table structures, columns, indexes, and constraints
  • Data Synchronization - Sync data with full or incremental strategies
  • Data Export - Export tables to JSON, CSV, or SQL format
  • Cross-Database Support - PostgreSQL ↔ MySQL/MariaDB
  • Beautiful CLI - Rich terminal output with colors, progress bars, and tables
  • Configuration File Support - YAML config for complex setups

πŸš€ Installation

Using Go Install
go install github.com/anuryadi/ditto@latest
From Source
git clone https://github.com/anuryadi/ditto.git
cd ditto
make build
Binary Releases

Download pre-built binaries from the Releases page.

πŸ“– Quick Start

Compare Database Schemas
# Compare PostgreSQL to MySQL
ditto compare \
  --source "postgres://user:pass@localhost:5432/source_db" \
  --target "mysql://user:pass@localhost:3306/target_db"

# Output to JSON
ditto compare \
  --source "postgres://user:pass@localhost/db1" \
  --target "mysql://user:pass@localhost/db2" \
  --format json \
  --output diff.json
Sync Data Between Databases
# Full sync
ditto sync \
  --source "postgres://user:pass@localhost/source" \
  --target "mysql://user:pass@localhost/target" \
  --tables users,orders,products

# Dry run (preview without changes)
ditto sync \
  --source "postgres://..." \
  --target "mysql://..." \
  --dry-run
Export Table Data
# Export to JSON
ditto export \
  --source "postgres://user:pass@localhost/db" \
  --table users \
  --format json \
  --output users.json

# Export to CSV
ditto export \
  --source "mysql://user:pass@localhost/db" \
  --table orders \
  --format csv \
  --output orders.csv

βš™οΈ Configuration

Create a .ditto.yaml file in your home directory or use --config flag:

source:
  driver: postgres
  host: localhost
  port: 5432
  database: source_db
  user: postgres
  password: ${DB_PASSWORD}  # Environment variable

target:
  driver: mysql
  host: localhost
  port: 3306
  database: target_db
  user: root
  password: ${DB_PASSWORD}

sync:
  strategy: full  # full, incremental
  batch_size: 1000
  tables:
    - name: users
      primary_key: id
      timestamp_column: updated_at
    - name: orders
      primary_key: id

logging:
  level: info
  format: console

πŸ”§ Commands

Command Description
ditto compare Compare schemas between source and target database
ditto sync Synchronize data from source to target
ditto export Export table data to file
ditto version Show version information
Global Flags
Flag Description
--config Path to config file (default: ~/.ditto.yaml)
-v, --verbose Enable verbose output
-h, --help Show help

πŸ—οΈ Architecture

ditto/
β”œβ”€β”€ cmd/                    # CLI commands (Cobra)
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ config/            # Configuration management (Viper)
β”‚   β”œβ”€β”€ database/          # Database drivers (PostgreSQL, MySQL)
β”‚   β”œβ”€β”€ schema/            # Schema comparison logic
β”‚   β”œβ”€β”€ sync/              # Data synchronization engine
β”‚   β”œβ”€β”€ export/            # Export handlers (JSON, CSV, SQL)
β”‚   └── ui/                # Terminal UI components (pterm)
└── pkg/
    └── logger/            # Structured logging (zerolog)

πŸ§ͺ Development

# Install dependencies
go mod download

# Run tests
make test

# Run with coverage
make coverage

# Lint code
make lint

# Build for all platforms
make build-all

πŸ“ Roadmap

  • SQLite support
  • Oracle Database support
  • Scheduled sync with cron
  • Web dashboard for monitoring
  • CDC (Change Data Capture) support

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments


Made with ❀️ by Ari Nuryadi

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
internal
ui
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL