Skip to content

Commit

Permalink
sea-orm-migration: bump clap version to 3.1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanh Van committed May 10, 2022
1 parent 51c8b30 commit 8e14e08
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
2 changes: 1 addition & 1 deletion sea-orm-migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ path = "src/lib.rs"
[dependencies]
async-std = { version = "^1", features = ["attributes", "tokio1"] }
async-trait = { version = "^0.1" }
clap = { version = "^2.33" }
clap = { version = "^3.1.17", features = ["env"] }
dotenv = { version = "^0.15" }
sea-orm = { version = "^0.8.0", path = "../", default-features = false, features = ["macros"] }
sea-orm-cli = { version = "^0.8.0", path = "../sea-orm-cli", default-features = false }
Expand Down
49 changes: 28 additions & 21 deletions sea-orm-migration/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use clap::App;
use clap::Command;
use dotenv::dotenv;
use std::{fmt::Display, process::exit};
use tracing_subscriber::{prelude::*, EnvFilter};
Expand All @@ -19,21 +19,21 @@ where
get_matches(migrator, db, app).await;
}

pub async fn get_matches<M>(_: M, db: &DbConn, app: App<'static, 'static>)
pub async fn get_matches<M>(_: M, db: &DbConn, app: Command<'static>)
where
M: MigratorTrait,
{
let matches = app.get_matches();
let mut verbose = false;
let filter = match matches.subcommand() {
(_, None) => "sea_schema::migration=info",
(_, Some(args)) => match args.is_present("VERBOSE") {
Some((_, args)) => match args.is_present("VERBOSE") {
true => {
verbose = true;
"debug"
}
false => "sea_schema::migration=info",
},
None => "sea_schema::migration=info",
};
let filter_layer = EnvFilter::try_new(filter).unwrap();
if verbose {
Expand All @@ -53,23 +53,30 @@ where
.init()
};
match matches.subcommand() {
("fresh", _) => M::fresh(db).await,
("refresh", _) => M::refresh(db).await,
("reset", _) => M::reset(db).await,
("status", _) => M::status(db).await,
("up", None) => M::up(db, None).await,
("down", None) => M::down(db, Some(1)).await,
("up", Some(args)) => {
let str = args.value_of("NUM_MIGRATION").unwrap_or_default();
let steps = str.parse().ok();
M::up(db, steps).await
}
("down", Some(args)) => {
let str = args.value_of("NUM_MIGRATION").unwrap();
let steps = str.parse().ok().unwrap_or(1);
M::down(db, Some(steps)).await
}
_ => M::up(db, None).await,
Some((cmd, args)) => match cmd {
"fresh" => M::fresh(db).await,
"refresh" => M::refresh(db).await,
"reset" => M::reset(db).await,
"status" => M::status(db).await,
"up" => match args.subcommand() {
Some(_) => {
let str = args.value_of("NUM_MIGRATION").unwrap_or_default();
let steps = str.parse().ok();
M::up(db, steps).await
}
None => M::up(db, None).await,
},
"down" => match args.subcommand() {
Some(_) => {
let str = args.value_of("NUM_MIGRATION").unwrap();
let steps = str.parse().ok().unwrap_or(1);
M::down(db, Some(steps)).await
}
None => M::down(db, Some(1)).await,
},
_ => M::up(db, None).await,
},
None => M::up(db, None).await,
}
.unwrap_or_else(handle_error);
}
Expand Down
8 changes: 4 additions & 4 deletions sea-orm-migration/src/manager.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use sea_orm::sea_query::{
extension::postgres::{TypeAlterStatement, TypeCreateStatement, TypeDropStatement},
Alias, Expr, ForeignKeyCreateStatement, ForeignKeyDropStatement, IndexCreateStatement,
IndexDropStatement, Query, TableAlterStatement, TableCreateStatement, TableDropStatement,
TableRenameStatement, TableTruncateStatement,
ForeignKeyCreateStatement, ForeignKeyDropStatement, IndexCreateStatement, IndexDropStatement,
TableAlterStatement, TableCreateStatement, TableDropStatement, TableRenameStatement,
TableTruncateStatement,
};
use sea_orm::{Condition, ConnectionTrait, DbBackend, DbConn, DbErr, Statement, StatementBuilder};
use sea_orm::{ConnectionTrait, DbBackend, DbConn, DbErr, StatementBuilder};
use sea_schema::{mysql::MySql, postgres::Postgres, probe::SchemaProbe, sqlite::Sqlite};

/// Helper struct for writing migration scripts in migration file
Expand Down

0 comments on commit 8e14e08

Please sign in to comment.