From 65164bf189507f8eaf84a087b6ef41f531b90a2a Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 21 Apr 2021 16:26:20 +0100 Subject: [PATCH] FIX: Do not dump schema during production database migrations (#12785) It's important that we don't perform pg_dumps against databases running behind pgbouncer. We had an old monkey-patch to prevent this, but following some [recent internal rails refactoring](https://github.com/rails/rails/commit/5488686851978c64346a0c03d2b6541cf2a94879), the patch no longer works. Instead, we can use the official `config.active_record.dump_schema_after_migration` option. Setting this to false in production is recommended by Rails, and is the default for newly generated Rails applications. --- Rakefile | 4 ---- config/environments/production.rb | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index dc7fdf2ecfd..d0e674f5aba 100755 --- a/Rakefile +++ b/Rakefile @@ -7,7 +7,3 @@ require File.expand_path('../config/application', __FILE__) Discourse::Application.load_tasks - -# this prevents crashes when migrating a database in production in certain -# PostgreSQL configuations when trying to create structure.sql -Rake::Task["db:structure:dump"].clear if Rails.env.production? diff --git a/config/environments/production.rb b/config/environments/production.rb index 2f0b0d5d277..a523888a8d5 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -67,4 +67,5 @@ Discourse::Application.configure do config.developer_emails = emails.split(",").map(&:downcase).map(&:strip) end + config.active_record.dump_schema_after_migration = false end