From 631bfb2a2319fbdfce3884dd26a59afa7d01fda2 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Wed, 11 May 2022 09:48:03 +0300 Subject: [PATCH] FIX: Create PostgreSQL extensions before migrating (#16158) Enabled extensions are not saved in backups and thus not created when restoring a newer backup (that has a new extension) to an old site (that does not have the migration). --- lib/tasks/db.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 1d5a0ed709a..76c5284e996 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -215,6 +215,8 @@ task 'db:migrate' => ['load_config', 'environment', 'set_locale'] do |_, args| raise "Migration #{migrations.last.version} is timestamped in the future" if migrations.last.version > now_timestamp raise "Migration #{migrations.first.version} is timestamped before the epoch" if migrations.first.version < epoch_timestamp + %i[pg_trgm unaccent].each { |extension| DB.exec "CREATE EXTENSION IF NOT EXISTS #{extension}" } + ActiveRecord::Tasks::DatabaseTasks.migrate if !Discourse.is_parallel_test?