Enable --universal-time by default (#1420)

* Enable --universal-time by default

* Add `--local-time` flag

---------

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
This commit is contained in:
Chris Tsang 2023-01-29 10:56:46 +08:00 committed by GitHub
parent 59276eb897
commit a9aa139af2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -115,9 +115,21 @@ pub enum MigrateSubcommands {
#[clap(
action,
long,
help = "Generate migration file based on Utc time instead of Local time"
default_value = "true",
help = "Generate migration file based on Utc time",
conflicts_with = "local-time",
display_order = 1001
)]
universal_time: bool,
#[clap(
action,
long,
help = "Generate migration file based on Local time",
conflicts_with = "universal-time",
display_order = 1002
)]
local_time: bool,
},
#[clap(
about = "Drop all tables from the database, then reapply all migrations",

View File

@ -25,7 +25,8 @@ pub fn run_migrate_command(
Some(MigrateSubcommands::Generate {
migration_name,
universal_time,
}) => run_migrate_generate(migration_dir, &migration_name, universal_time)?,
local_time,
}) => run_migrate_generate(migration_dir, &migration_name, !local_time)?,
_ => {
let (subcommand, migration_dir, steps, verbose) = match command {
Some(MigrateSubcommands::Fresh) => ("fresh", migration_dir, None, verbose),

View File

@ -78,7 +78,8 @@ where
Some(MigrateSubcommands::Generate {
migration_name,
universal_time,
}) => run_migrate_generate(MIGRATION_DIR, &migration_name, universal_time)?,
local_time,
}) => run_migrate_generate(MIGRATION_DIR, &migration_name, !local_time)?,
_ => M::up(db, None).await?,
};