diff --git a/lib/site_settings/db_provider.rb b/lib/site_settings/db_provider.rb index 40c3f823e2d..6f291995d35 100644 --- a/lib/site_settings/db_provider.rb +++ b/lib/site_settings/db_provider.rb @@ -58,12 +58,7 @@ class SiteSettings::DbProvider # table is not in the db yet, initial migration, etc def table_exists? @table_exists ||= {} - begin - @table_exists[current_site] ||= ActiveRecord::Base.connection.table_exists?(@model.table_name) - rescue - STDERR.puts "No connection to db, unable to retrieve site settings! (normal when running db:create)" - @table_exists[current_site] = false - end + @table_exists[current_site] ||= ActiveRecord::Base.connection.table_exists?(@model.table_name) end end diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index b5e4d77d3be..d55ecb6d3c7 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -21,12 +21,23 @@ task 'db:environment:set' => [:load_config] do |_, args| end end -task 'db:create' => [:load_config] do |_, args| +task 'db:force_skip_persist' do + GlobalSetting.skip_db = true + GlobalSetting.skip_redis = true +end + +task 'db:create' do |_, args| if MultisiteTestHelpers.load_multisite? system("RAILS_DB=discourse_test_multisite rake db:create") end end +begin + reqs = Rake::Task['db:create'].prerequisites.map(&:to_sym) + Rake::Task['db:create'].clear_prerequisites + Rake::Task['db:create'].enhance(["db:force_skip_persist"] + reqs) +end + task 'db:drop' => [:load_config] do |_, args| if MultisiteTestHelpers.load_multisite? system("RAILS_DB=discourse_test_multisite rake db:drop")