From 31271cb697aec88e3150e9b5527273840b857cb6 Mon Sep 17 00:00:00 2001 From: Hooopo Date: Thu, 18 Aug 2022 12:00:12 +0800 Subject: [PATCH] feat(backend): support skip tiflash replica (#716) Update import.rake --- backend/lib/tasks/import.rake | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/backend/lib/tasks/import.rake b/backend/lib/tasks/import.rake index 8a05b4698ea..4c8b0110a0a 100644 --- a/backend/lib/tasks/import.rake +++ b/backend/lib/tasks/import.rake @@ -9,19 +9,21 @@ require_relative '../importer' namespace :gh do task :set_tiflash_replica => :environment do - ActiveRecord::Base.connection.execute("ALTER TABLE github_events SET TIFLASH REPLICA 1") - ActiveRecord::Base.connection.execute("ALTER TABLE db_repos SET TIFLASH REPLICA 1") - ActiveRecord::Base.connection.execute("ALTER TABLE collections SET TIFLASH REPLICA 1") - ActiveRecord::Base.connection.execute("ALTER TABLE collection_items SET TIFLASH REPLICA 1") - ActiveRecord::Base.connection.execute("ALTER TABLE web_framework_repos SET TIFLASH REPLICA 1") - ActiveRecord::Base.connection.execute("ALTER TABLE nocode_repos SET TIFLASH REPLICA 1") - ActiveRecord::Base.connection.execute("ALTER TABLE static_site_generator_repos SET TIFLASH REPLICA 1") - ActiveRecord::Base.connection.execute("ALTER TABLE web_framework_repos SET TIFLASH REPLICA 1") - ActiveRecord::Base.connection.execute("ALTER TABLE cn_repos SET TIFLASH REPLICA 1") - ActiveRecord::Base.connection.execute("ALTER TABLE cn_orgs SET TIFLASH REPLICA 1") - ActiveRecord::Base.connection.execute("ALTER TABLE js_framework_repos SET TIFLASH REPLICA 1") - ActiveRecord::Base.connection.execute("ALTER TABLE css_framework_repos SET TIFLASH REPLICA 1") - ActiveRecord::Base.connection.execute("ALTER TABLE users SET TIFLASH REPLICA 1") + if ENV["SKIP_REPLICA"].blank? + ActiveRecord::Base.connection.execute("ALTER TABLE github_events SET TIFLASH REPLICA 1") + ActiveRecord::Base.connection.execute("ALTER TABLE db_repos SET TIFLASH REPLICA 1") + ActiveRecord::Base.connection.execute("ALTER TABLE collections SET TIFLASH REPLICA 1") + ActiveRecord::Base.connection.execute("ALTER TABLE collection_items SET TIFLASH REPLICA 1") + ActiveRecord::Base.connection.execute("ALTER TABLE web_framework_repos SET TIFLASH REPLICA 1") + ActiveRecord::Base.connection.execute("ALTER TABLE nocode_repos SET TIFLASH REPLICA 1") + ActiveRecord::Base.connection.execute("ALTER TABLE static_site_generator_repos SET TIFLASH REPLICA 1") + ActiveRecord::Base.connection.execute("ALTER TABLE web_framework_repos SET TIFLASH REPLICA 1") + ActiveRecord::Base.connection.execute("ALTER TABLE cn_repos SET TIFLASH REPLICA 1") + ActiveRecord::Base.connection.execute("ALTER TABLE cn_orgs SET TIFLASH REPLICA 1") + ActiveRecord::Base.connection.execute("ALTER TABLE js_framework_repos SET TIFLASH REPLICA 1") + ActiveRecord::Base.connection.execute("ALTER TABLE css_framework_repos SET TIFLASH REPLICA 1") + ActiveRecord::Base.connection.execute("ALTER TABLE users SET TIFLASH REPLICA 1") + end end task :load_sample => :environment do