2021-01-31 02:38:35 +03:00
|
|
|
#![deny(clippy::all)]
|
|
|
|
|
2021-02-13 00:39:39 +03:00
|
|
|
mod commands;
|
2021-01-31 03:23:43 +03:00
|
|
|
mod config;
|
2021-02-05 01:37:25 +03:00
|
|
|
mod database;
|
2021-02-16 18:11:39 +03:00
|
|
|
mod databases;
|
2021-02-10 01:13:27 +03:00
|
|
|
mod error;
|
2021-02-08 23:42:13 +03:00
|
|
|
mod migration;
|
2021-01-31 02:54:23 +03:00
|
|
|
mod opts;
|
2021-02-05 01:37:25 +03:00
|
|
|
mod path;
|
2021-01-31 02:38:35 +03:00
|
|
|
|
2021-02-13 00:39:39 +03:00
|
|
|
use crate::error::StdResult;
|
2021-01-31 03:23:43 +03:00
|
|
|
use config::Config;
|
2021-02-13 00:39:39 +03:00
|
|
|
use opts::{AppOpt, Command, StructOpt};
|
2021-01-31 02:38:35 +03:00
|
|
|
|
2021-02-13 00:39:39 +03:00
|
|
|
fn main() -> StdResult<()> {
|
2021-01-31 02:38:35 +03:00
|
|
|
let opt = AppOpt::from_args();
|
2021-01-31 03:23:43 +03:00
|
|
|
|
2021-02-02 00:53:33 +03:00
|
|
|
match opt.command {
|
|
|
|
Command::Init => {
|
2021-02-13 00:39:39 +03:00
|
|
|
commands::initialize_migra_manifest(opt.config)?;
|
2021-02-01 23:51:23 +03:00
|
|
|
}
|
2021-02-13 00:39:39 +03:00
|
|
|
Command::Apply(opts) => {
|
2021-02-02 00:53:33 +03:00
|
|
|
let config = Config::read(opt.config)?;
|
2021-02-13 00:39:39 +03:00
|
|
|
commands::apply_sql(config, opts)?;
|
2021-01-31 02:38:35 +03:00
|
|
|
}
|
2021-02-13 00:39:39 +03:00
|
|
|
Command::Make(opts) => {
|
2021-02-03 01:03:56 +03:00
|
|
|
let config = Config::read(opt.config)?;
|
2021-02-13 00:39:39 +03:00
|
|
|
commands::make_migration(config, opts)?;
|
2021-02-03 01:03:56 +03:00
|
|
|
}
|
2021-02-02 23:50:42 +03:00
|
|
|
Command::List => {
|
|
|
|
let config = Config::read(opt.config)?;
|
2021-02-13 00:39:39 +03:00
|
|
|
commands::print_migration_lists(config)?;
|
2021-02-02 23:50:42 +03:00
|
|
|
}
|
2021-02-06 01:22:00 +03:00
|
|
|
Command::Upgrade => {
|
|
|
|
let config = Config::read(opt.config)?;
|
2021-02-13 00:39:39 +03:00
|
|
|
commands::upgrade_pending_migrations(config)?;
|
2021-02-06 01:22:00 +03:00
|
|
|
}
|
|
|
|
Command::Downgrade => {
|
2021-02-06 01:37:30 +03:00
|
|
|
let config = Config::read(opt.config)?;
|
2021-02-13 00:39:39 +03:00
|
|
|
commands::downgrade_applied_migrations(config)?;
|
2021-02-02 00:53:33 +03:00
|
|
|
}
|
2021-01-31 02:38:35 +03:00
|
|
|
}
|
2021-01-31 03:23:43 +03:00
|
|
|
|
|
|
|
Ok(())
|
2021-01-31 02:38:35 +03:00
|
|
|
}
|