Skip to content

Commit 32b7b80

Browse files
authored
Merge pull request #1 from EasyPost/bump
bump a whole bunch of dependencies; add features
2 parents b03be02 + 57a98fc commit 32b7b80

File tree

4 files changed

+74
-41
lines changed

4 files changed

+74
-41
lines changed

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
0.2.0
2+
=====
3+
- Bump a bunch of dependencies, including `clap` and `mysql`
4+
- Add some feature flags controlling the `mysql` dependency (documented in [README.md](README.md))
5+
6+
0.1.0
7+
=====
8+
- Initial release

Cargo.toml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
[package]
22
name = "rmmm"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
description = "Rust MySQL Migration Manager"
55
repository = "https://github.com/EasyPost/rmmm"
66
authors = ["James Brown <[email protected]>"]
77
readme = "README.md"
88
edition = "2021"
99
license = "ISC"
10+
keywords = ["database", "mysql", "schema"]
11+
categories = ["command-line-utilities", "database", "development-tools"]
1012

1113
[dependencies]
1214
anyhow = "1"
1315
chrono = "0.4"
14-
clap = "2"
16+
clap = { version = "3", features=["std", "color", "suggestions", "cargo", "env", "wrap_help"] }
1517
derive_more = "0.99"
1618
fern = {version = "0.6", features=["colored"]}
1719
itertools = "0.10"
1820
lazy_static = "1"
1921
log = "0.4"
20-
mysql = "21"
22+
mysql = { version = "22", default_features = false }
23+
# don't pin these; they're pinned by `mysql` and are just here to set features
24+
flate2 = { version = "*", default_features = false, features = ["zlib"] }
25+
mysql_common = { version = "*", default_features = false, features = ["time03"]}
2126
regex = "1"
22-
tabled = "0.3"
27+
tabled = "0.4"
2328
tempfile = "3"
29+
30+
[features]
31+
default = ["uuid"]
32+
native-tls = ["mysql/native-tls"]
33+
rustls-tls = ["mysql/rustls-tls"]
34+
uuid = ["mysql_common/uuid"]

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
This is a small Rust application for managing database migrations for MySQL.
22

3-
![CI](https://github.com/EasyPost/rmmm/workflows/CI/badge.svg?branch=master)
3+
[![CI](https://github.com/EasyPost/rmmm/workflows/CI/badge.svg?branch=master)](https://github.com/EasyPost/rmmm/actions/workflows/ci.yml)
44

55
It compiles into a single binary called `rmmm`.
66

@@ -15,7 +15,9 @@ Basic usage:
1515
1. `rmmm status` will show all pending migrations
1616
1. `rmmm upgrade latest` will apply pending migrations. You can also upgrade (or downgrade) to a specific version.
1717

18-
Versions are just incrementing integers for simplicity.
18+
Modifying actions will only print out what they would do by default and must be run with `--execute` to make changes.
19+
20+
Schema versions are just incrementing integers for simplicity.
1921

2022
Configuration is typically through environment variables:
2123

@@ -26,6 +28,17 @@ Configuration is typically through environment variables:
2628

2729
This work is licensed under the ISC license, a copy of which can be found in [LICENSE.txt](LICENSE.txt).
2830

31+
Features
32+
--------
33+
RMMM supports the following feature flags:
34+
35+
| Name | Meaning | Enabled by default |
36+
| `uuid` | Add support for native MySQL UUID types ||
37+
| `native-tls` | Use [native-tls](https://crates.io/crates/native-tls) to get SSL support via the local library (OpenSSL, etc) | |
38+
| `rustls-tls` | Use [rustls](https://crates.io/crates/rustls) to get SSL support | |
39+
40+
You can enable exactly zero or one of `native-tls` or `rustls-tls`.
41+
2942
Why?
3043
----
3144
There are lots of migration management tools. A popular stand-alone choice is

src/main.rs

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#![forbid(unsafe_code)]
2+
13
use std::collections::{BTreeMap, BTreeSet};
24
use std::env;
35

46
use anyhow::Context;
5-
use clap::{Arg, SubCommand};
7+
use clap::Arg;
68
use derive_more::Display;
79
use itertools::Itertools;
810
use log::{debug, error, info};
@@ -101,7 +103,7 @@ fn command_status(state: MigrationState) -> anyhow::Result<()> {
101103
}
102104
})
103105
.collect::<Vec<_>>();
104-
let table = tabled::Table::new(&data).with(tabled::Style::pseudo_clean());
106+
let table = tabled::Table::new(&data).with(tabled::Style::PSEUDO_CLEAN);
105107
println!("{}", table);
106108
Ok(())
107109
}
@@ -144,7 +146,7 @@ fn command_upgrade(matches: &clap::ArgMatches, state: MigrationState) -> anyhow:
144146
})
145147
.collect::<Vec<_>>();
146148
let table = tabled::Table::new(&plan_data)
147-
.with(tabled::Style::pseudo_clean())
149+
.with(tabled::Style::PSEUDO_CLEAN)
148150
.with(tabled::Modify::new(tabled::Column(2..=2)).with(tabled::Alignment::left()));
149151
println!("Migration plan:");
150152
println!("{}", table);
@@ -180,79 +182,78 @@ fn command_reset(matches: &clap::ArgMatches) -> anyhow::Result<()> {
180182
}
181183

182184
fn main() -> anyhow::Result<()> {
183-
let matches = clap::App::new(env!("CARGO_PKG_NAME"))
184-
.version(env!("CARGO_PKG_VERSION"))
185-
.author(env!("CARGO_PKG_AUTHORS"))
186-
.about(env!("CARGO_PKG_DESCRIPTION"))
187-
.global_settings(&[clap::AppSettings::ColorAuto, clap::AppSettings::ColoredHelp])
185+
let matches = clap::App::new(clap::crate_name!())
186+
.version(clap::crate_version!())
187+
.author(clap::crate_authors!())
188+
.about(clap::crate_description!())
188189
.arg(
189-
Arg::with_name("migration_path")
190-
.short("p")
190+
Arg::new("migration_path")
191+
.short('p')
191192
.long("migration-path")
192193
.takes_value(true)
193194
.default_value("db")
194195
.env("MIGRATION_PATH")
195196
.help("Directory in which state is stored"),
196197
)
197198
.arg(
198-
Arg::with_name("quiet")
199-
.short("q")
199+
Arg::new("quiet")
200+
.short('q')
200201
.long("quiet")
201202
.help("Be less noisy when logging"),
202203
)
203204
.arg(
204-
Arg::with_name("verbose")
205-
.short("v")
205+
Arg::new("verbose")
206+
.short('v')
206207
.long("verbose")
207-
.multiple(true)
208+
.multiple_occurrences(true)
208209
.help("Be more noisy when logging"),
209210
)
210-
.subcommand(SubCommand::with_name("status").about("Show the current status of migrations"))
211+
.subcommand(clap::App::new("status").about("Show the current status of migrations"))
211212
.subcommand(
212-
SubCommand::with_name("generate")
213+
clap::App::new("generate")
213214
.about("Generate a new migration")
214215
.arg(
215-
Arg::with_name("label")
216+
Arg::new("label")
216217
.required(true)
217218
.help("Descriptive one-line label for the migration"),
218219
),
219220
)
220221
.subcommand(
221-
SubCommand::with_name("upgrade")
222+
clap::App::new("upgrade")
222223
.about("Upgrade to the given revision")
223224
.arg(
224-
Arg::with_name("revision")
225+
Arg::new("revision")
225226
.required(true)
226227
.help("Revision to which to upgrade (or 'latest')"),
227228
)
228229
.arg(
229-
Arg::with_name("execute")
230-
.short("x")
230+
Arg::new("execute")
231+
.short('x')
231232
.long("execute")
232233
.help("Actually upgrade (otherwise will just print what will be done"),
233234
),
234235
)
235236
.subcommand(
236-
SubCommand::with_name("downgrade")
237+
clap::App::new("downgrade")
237238
.about("Downgrade to the given revision")
238239
.arg(
239-
Arg::with_name("revision")
240+
Arg::new("revision")
240241
.required(true)
241242
.help("Revision to which to downgrade"),
242243
)
243244
.arg(
244-
Arg::with_name("execute")
245-
.short("x")
245+
Arg::new("execute")
246+
.short('x')
246247
.long("execute")
247248
.help("Actually upgrade (otherwise will just print what will be done"),
248249
),
249250
)
250251
.subcommand(
251-
SubCommand::with_name("reset")
252+
clap::App::new("reset")
252253
.about("Drop all tables and totally reset the database (DANGEROUS)")
253254
.arg(
254-
Arg::with_name("execute")
255-
.short("x")
255+
Arg::new("execute")
256+
.short('x')
256257
.long("execute")
257258
.help("Actually reset"),
258259
),
@@ -264,20 +265,20 @@ fn main() -> anyhow::Result<()> {
264265
let current_state = MigrationState::load(matches.value_of("migration_path").unwrap())?;
265266

266267
match matches.subcommand() {
267-
("generate", Some(smatches)) => {
268+
Some(("generate", smatches)) => {
268269
current_state.generate(smatches.value_of("label").unwrap())?
269270
}
270-
("status", _) => {
271+
Some(("status", _)) => {
271272
command_status(current_state)?;
272273
}
273-
("upgrade", Some(smatches)) => {
274+
Some(("upgrade", smatches)) => {
274275
command_upgrade(smatches, current_state)?;
275276
}
276-
("downgrade", Some(smatches)) => {
277+
Some(("downgrade", smatches)) => {
277278
command_upgrade(smatches, current_state)?;
278279
}
279-
("reset", Some(smatches)) => command_reset(smatches)?,
280-
(_, _) => {
280+
Some(("reset", smatches)) => command_reset(smatches)?,
281+
_ => {
281282
anyhow::bail!("Must pass a command!");
282283
}
283284
};

0 commit comments

Comments
 (0)