From 069a0bd6eeb41070abd58ae8df68ae3953eef0ad Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Mon, 8 Jul 2024 11:01:06 -0500 Subject: [PATCH] DEV: Add force option to discourse remap command (#27770) --- script/discourse | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/script/discourse b/script/discourse index 65190bfdfb4..5cc8c9d13d4 100755 --- a/script/discourse +++ b/script/discourse @@ -8,7 +8,7 @@ class DiscourseCLI < Thor true end - desc "remap [--global,--regex] FROM TO", "Remap a string sequence across all tables" + desc "remap [--global,--regex,--force] FROM TO", "Remap a string sequence across all tables" long_desc <<-TEXT Replace a string sequence FROM with TO across all tables. @@ -33,6 +33,7 @@ class DiscourseCLI < Thor TEXT option :global, type: :boolean option :regex, type: :boolean + option :force, type: :boolean def remap(from, to) load_rails @@ -48,10 +49,12 @@ class DiscourseCLI < Thor puts "WILL RUN ON '#{RailsMultisite::ConnectionManagement.current_db}' DB" end - puts "THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES)" - if STDIN.gets.strip.upcase != "YES" - puts "aborting." - exit 1 + unless options[:force] + puts "THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES)" + if STDIN.gets.strip.upcase != "YES" + puts "aborting." + exit 1 + end end if options[:global]