Skip to content

Commit

Permalink
FIX: Do not dump schema during production database migrations (discou…
Browse files Browse the repository at this point in the history
…rse#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](rails/rails@5488686),
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.
  • Loading branch information
davidtaylorhq authored Apr 21, 2021
1 parent e4f1760 commit 65164bf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
4 changes: 0 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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?
1 change: 1 addition & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@
config.developer_emails = emails.split(",").map(&:downcase).map(&:strip)
end

config.active_record.dump_schema_after_migration = false
end

0 comments on commit 65164bf

Please sign in to comment.