# Midas (cargo-migrate)
[](https://crates.io/crates/midas)
[](https://crates.io/crates/midas)
[](https://github.com/ffimnsr/midas-rs/blob/master/LICENSE-APACHE)
[](https://github.com/ffimnsr/midas-rs/blob/master/.github/workflows/ci.yaml)
> So Midas, king of Lydia, swelled at first with pride
> when he found he could transform everything he touched
> to gold; but when he beheld his food grow rigid and his
> drink harden into golden ice then he understood that
> this gift was a bane and in his loathing for gold, cursed
> his prayer.
> - from In Rufinem, Claudian
Do painless migrations.
## Supported Database
- [x] PostgresSQL
- [x] CockroachDB
- [x] MySQL
- [x] MariaDB
- [x] SQLite3
- [ ] MSSQL
- [ ] Cassandra
- [ ] OracleDB
## Usage
### Using CLI
Here is a sample command line usage of `midas`.
```shell
midas --database 'postgres://postgres:postgres@localhost:5432/startup' --source migrations up
...or...
midas --database 'mysql://root:mysql@localhost:3306/startup' --source migrations up
...or...
midas --database 'file:///./data.db' --source migrations up
```
NOTE: For sqlite database use correct URI filenames stated here: https://www.sqlite.org/c3ref/open.html#urifilenameexamples
or you could also use the `cargo migrate` to integrate it on your cargo workflow.
The command will execute all **special** (up) SQL migrations files to the database. \
Here are the available subcommands:
```shell
create Creates a timestamped migration file
down Remove all applied migrations
drop Drops everything inside the database
redo Redo the last migration
revert Reverts the last migration
init Setups and creates initial file directory and env
status Checks the status of the migration
up Apply all non-applied migrations
```
For more info see `--help`.
## Installation
If you're into **Rust** then you can use `cargo` to install.
* The minimum supported version of Rust is `1.37.0`.
```shellbash
cargo install midas
```
Binary for different OS distribution can be downloaded [here](https://github.com/ffimnsr/midas/releases).
## What's in the Roadmap
- [ ] TOML DSL for creating database objects
- [-] Setup multiple drivers (e.g. MySQL, Sqlite3, etc.)
- [ ] Add functionality for `setup` and `drop` commands.
- [ ] More to come.
## License
Licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.