From a9aa139af269078ee0ee6268846e7d1f9bf35ddb Mon Sep 17 00:00:00 2001 From: Chris Tsang Date: Sun, 29 Jan 2023 10:56:46 +0800 Subject: [PATCH] Enable --universal-time by default (#1420) * Enable --universal-time by default * Add `--local-time` flag --------- Co-authored-by: Billy Chan --- sea-orm-cli/src/cli.rs | 14 +++++++++++++- sea-orm-cli/src/commands/migrate.rs | 3 ++- sea-orm-migration/src/cli.rs | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sea-orm-cli/src/cli.rs b/sea-orm-cli/src/cli.rs index a7a2e0e77..7958f9962 100644 --- a/sea-orm-cli/src/cli.rs +++ b/sea-orm-cli/src/cli.rs @@ -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", diff --git a/sea-orm-cli/src/commands/migrate.rs b/sea-orm-cli/src/commands/migrate.rs index f929fe487..51081283d 100644 --- a/sea-orm-cli/src/commands/migrate.rs +++ b/sea-orm-cli/src/commands/migrate.rs @@ -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), diff --git a/sea-orm-migration/src/cli.rs b/sea-orm-migration/src/cli.rs index e7890d5e5..fef517364 100644 --- a/sea-orm-migration/src/cli.rs +++ b/sea-orm-migration/src/cli.rs @@ -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?, };