A powerful, cross-platform command-line database migration tool built in Go that supports PostgreSQL, MySQL/MariaDB, and Cassandra/ScyllaDB databases. This tool helps you manage, create, and execute database migrations efficiently with a focus on developer experience and reliability.
- PostgreSQL with full user management
- MySQL/MariaDB with InnoDB and UTF8MB4
- Cassandra/ScyllaDB with advanced clustering
- Version-controlled migrations
- Forward and rollback support (single, multiple, all)
- Transaction safety for SQL databases
- Migration status tracking with colored output
- Fresh migrations (drop and recreate)
- Create databases and keyspaces
- Manage users and privileges
- Multiple privilege levels (read, write, all, admin)
- Super user support for administrative tasks
- Simple command-line interface
- Colored terminal output
- Clear error messages
- Progress indicators
- Detailed logging
- Auto-update functionality
-
Download the appropriate executable for your system from the releases page:
- Linux:
jbmdb-linux-amd64
- Windows:
jbmdb-windows-amd64.exe
- macOS:
jbmdb-darwin-amd64
- Linux:
-
Rename the downloaded file to
jbmdb
(orjbmdb.exe
on Windows) -
Move the executable to a directory in your system PATH:
# Linux/macOS sudo mv jbmdb /usr/local/bin/ sudo chmod +x /usr/local/bin/jbmdb # Windows # Move jbmdb.exe to C:\Windows\System32\
When you run any command for the first time, the tool will:
- Ask which databases you want to configure
- Ask for your database credentials (with secure password input)
- Create a
.jbmdb.conf
file with your provided credentials - Create necessary migration directories
- Set up initial configuration
You can also configure each database using their respective init commands:
jbmdb postgres-init # Configure PostgreSQL
jbmdb mysql-init # Configure MySQL/MariaDB
jbmdb cql-init # Configure Cassandra/ScyllaDB
The tool uses a .jbmdb.conf
file in JSON format:
{
"postgres": {
"migration_path": "migrations/postgres",
"sql_folder": "sql",
"host": "localhost",
"port": "5432",
"user": "myapp",
"password": "secret",
"dbname": "myapp_db",
"super_user": "postgres",
"super_pass": "postgres"
},
"mysql": {
"migration_path": "migrations/mysql",
"sql_folder": "sql",
"host": "localhost",
"port": "3306",
"user": "myapp",
"password": "secret",
"dbname": "myapp_db",
"super_user": "root",
"super_pass": "root"
},
"cql": {
"migration_path": "migrations/cql",
"cql_folder": "cql",
"hosts": ["localhost"],
"port": 9042,
"user": "myapp",
"password": "secret",
"keyspace": "myapp_space",
"super_user": "cassandra",
"super_pass": "cassandra",
"datacenter": "dc1",
"consistency": "quorum"
}
}
jbmdb config # Set up migration paths
jbmdb version # Check version
jbmdb update # Check for updates
The following commands work for all databases. Replace <db>
with:
postgres
for PostgreSQLmysql
for MySQL/MariaDBcql
for Cassandra/ScyllaDB
# Migration Commands
jbmdb <db>-migration create_users_table # Create new migration
jbmdb <db>-migrate # Run pending migrations
jbmdb <db>-rollback # Rollback last migration
jbmdb <db>-rollback:all # Rollback all migrations
jbmdb <db>-rollback:3 # Rollback last 3 migrations
jbmdb <db>-list # List all migrations
jbmdb <db>-fresh # Drop and remigrate
# User Management
jbmdb <db>-create-user:read # Read-only access
jbmdb <db>-create-user:write # Read/write access
jbmdb <db>-create-user:all # All privileges
jbmdb <db>-create-user:admin # Admin privileges
# Database Creation
jbmdb postgres-create-db # Create PostgreSQL database
jbmdb mysql-create-db # Create MySQL database
jbmdb cql-create-keyspace:SimpleStrategy:3 # Create Cassandra keyspace
-- Up Migration
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Down Migration
DROP TABLE users;
-- Up Migration
CREATE TABLE users (
id uuid PRIMARY KEY,
name text,
created_at timestamp,
updated_at timestamp
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'ALL'}
AND compaction = {'class': 'SizeTieredCompactionStrategy'};
-- Down Migration
DROP TABLE users;
- Must start with
create_
- Must end with
_table
- Single table names must be plural:
create_users_table
create_user_comments_table
-
SimpleStrategy: For single-datacenter deployments
jbmdb cql-create-keyspace:SimpleStrategy:3 # RF=3
-
NetworkTopologyStrategy: For multi-datacenter deployments
jbmdb cql-create-keyspace:NetworkTopologyStrategy:2 # RF=2 per DC
- Added MySQL/MariaDB support with InnoDB and UTF8MB4
- Enhanced Cassandra/ScyllaDB support:
- Multi-node cluster configuration
- Flexible replication strategies
- Custom consistency levels
- Datacenter-aware operations
- Improved user management and privileges
- Better error handling and colored output
- Comprehensive test suite
- Updated documentation and examples
- Initial release with PostgreSQL and ScyllaDB support
Hi, I'm Joseph Barasa, a passionate Go developer focused on building high-performance, scalable systems.
- Portfolio: jbarasa.com
- Email: [email protected]
- Specialized in: Distributed systems, microservices, and high-performance applications
- Open to exciting Golang projects and opportunities
This project is licensed under the Mozilla Public License Version 2.0 - see the LICENSE file for details.
Copyright (C) 2024 Joseph Barasa