
Maestro
Maestro is a powerful Go library and CLI tool designed for seamless database migration management.
Just as a maestro orchestrates a symphony, maestro orchestrates your database changes, conducting migrations with precision and grace. It ensures your database schema evolves smoothly, keeping all your environments in perfect harmony while maintaining a clear record of every change.
Quick Start
# Install as CLI tool
go install github.com/maestro-go/maestro@latest
# Create a new migration
maestro create add_users_table -m ./migrations --with-down
# Run migrations
maestro migrate
Index
Installation
go install github.com/maestro-go/maestro@latest
Go Library
go get github.com/maestro-go/maestro/core
Supported Databases
Currently Supported
In Progress
- π§ MySQL
- π§ SQLite
- π§ ClickHouse
Key Features
- β¨ Manage up/down migrations effortlessly
- π οΈ Repair migrations seamlessly
- π Validate migrations with MD5 checksums
- πͺ Utilize a flexible hooks system
- π Track migration history clearly
Upcoming Features
- π Built-in SSH tunnel support
Migrations
Migrations Files
Maestro uses a simple naming convention for migration files:
π migrations/
βββ π V001_create_users.sql # Up migration
βββ π V001_create_users.down.sql # Down migration (optional)
βββ π V002_add_email_column.sql
βββ π V002_add_email_column.down.sql
If you're using hooks, the recommended folder structure is:
π migrations/
βββ π V001_example.sql
βββ π V001_example.down.sql
βββ π before/
βββ π beforeEach/
βββ π beforeVersion/
βββ π afterVersion/
βββ π afterEach/
βββ π after/
βββ π repeatable/
βββ π repeatableDown/
Create new migrations using the CLI:
maestro create add_users_table -m ./migrations --with-down
Migrations Destination
Control which migrations to run using destination:
# Run migrations up to 10
maestro migrate --destination 10
# Run migrations down to 5
maestro migrate --down --destination 5
Migrating down
When performing a downward migration, ensure that each upward migration has a corresponding downward migration file.
Failure to do so may result in inconsistencies.
Migrations Repair
If you encounter checksum mismatches or other issues with your migration history, you can use the repair command to fix them. This command recalculates and updates the checksums of your migration files, ensuring that the recorded checksums match the actual files.
maestro repair
Note: Using repair is not recommended as the primary fix. However, if you need to change old migrations and hooks cannot solve the problem, the repair command can be used to maintain the integrity of your migration history.
Migrations Status
Check the current migrations status, like latest applied migration and failed migrations:
maestro status
Warnings
Force
You can force migrations using the force flag/config. However, it is not compatible with the in-transaction flag/config. When using transactions, forcing a migration that encounters an error will result in the entire transaction being rolled back.
Documentation
Detailed documentation is available:
Contributing
We welcome contributions! Please read our:
License
This project is licensed under the MIT License - see the LICENSE file for details.