https://github.com/easypost/rmmm
Rust MySQL Migration Manager
https://github.com/easypost/rmmm
Last synced: 6 months ago
JSON representation
Rust MySQL Migration Manager
- Host: GitHub
- URL: https://github.com/easypost/rmmm
- Owner: EasyPost
- License: isc
- Created: 2021-12-16T22:24:15.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2025-04-04T20:40:51.000Z (10 months ago)
- Last Synced: 2025-06-22T17:17:31.811Z (7 months ago)
- Language: Rust
- Size: 85 KB
- Stars: 6
- Watchers: 33
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE.txt
Awesome Lists containing this project
README
This is a small Rust application for managing database migrations for MySQL.
[](https://github.com/EasyPost/rmmm/actions/workflows/ci.yml)
[](https://crates.io/crates/rmmm)
[](LICENSE.txt)
It compiles into a single binary called `rmmm`.
Configuration, by default, is through the `db/` directory of the directory in which `rmmm` is invoked. Migrations will
live in `db/migrations/v{version}.sql`, rollbacks in `db/migrations/v{version}_downgrade.sql`,
and structure will be dumped to `db/structure.sql`.
Basic usage:
1. `cargo install rmmm`
1. `rmmm generate foo` will pop up an editor for you to write a migration. Migrations may be any number of SQL statements on lines by themselves ending with the `;` character. Comments are stripped.
1. `rmmm status` will show all pending migrations
1. `rmmm upgrade latest` will apply pending migrations. You can also upgrade (or downgrade) to a specific version.
Modifying actions will only print out what they would do by default and must be run with `--execute` to make changes.
Schema versions are just incrementing integers for simplicity.
Configuration is typically through environment variables:
| Environment Variable | Meaning |
|----------------------|---------|
| `$DATABASE_URL` | URL (`mysql://`) to connect to MySQL |
| `$DATABASE_DSN` | DSN (as per [go-sql-driver](https://github.com/go-sql-driver/mysql/#user-content-dsn-data-source-name)) to connect to MySQL |
| `$MIGRATION_PATH` | Path to store state (defaults to `./db`) |
Either `$DATABASE_URL` or `$DATABASE_DSN` must be passed. They can also be passed to the program as `--database-dsn` or `--database-url`.
This work is licensed under the ISC license, a copy of which can be found in [LICENSE.txt](LICENSE.txt).
Features
--------
RMMM supports the following feature flags:
| Name | Meaning | Enabled by default |
|------|---------|--------------------|
| `uuid` | Add support for native MySQL UUID types | ✓ |
| `native-tls` | Use [native-tls](https://crates.io/crates/native-tls) to get SSL support via the local library (OpenSSL, etc) | |
| `rustls-tls` | Use [rustls](https://crates.io/crates/rustls) to get SSL support | |
You can enable exactly zero or one of `native-tls` or `rustls-tls`.
Why?
----
There are lots of migration management tools. A popular stand-alone choice is
[dogfish](https://github.com/dwb/dogfish); there are also tools using richer libraries for various
ecosystems such as [barrel](https://git.irde.st/spacekookie/barrel) for diesel, or Python's
[alembic](https://alembic.sqlalchemy.org/en/latest/).
This tool is closest to dogfish, but avoids the various shell injection risks and uses the same `DATABASE_URL`
configuration string as other common frameworks (Rust's `mysql`, Python's `sqlalchemy`, Ruby's `activerecord`, etc).