A platform for community discussion. Free, open, simple.
FIX: Restoring backup could fail due to missing `discourse_functions` (#29332)
Gerhard Schlager07ff21d04531
diff --git a/lib/backup_restore/database_restorer.rb b/lib/backup_restore/database_restorer.rbindex e913ba99324..d8ce2dfb1ec 100644--- a/lib/backup_restore/database_restorer.rb+++ b/lib/backup_restore/database_restorer.rb@@ -49,9 +49,11 @@ module BackupRestoreActiveRecord::Base.connection.drop_schema(BACKUP_SCHEMA) if backup_schema_dropable?end- def self.core_migration_files+ def self.all_migration_filesDir[Rails.root.join(Migration::SafeMigrate.post_migration_path, "**/*.rb")] +- Dir[Rails.root.join("db/migrate/*.rb")]+ Dir[Rails.root.join("db/migrate/*.rb")] ++ Dir[Rails.root.join("plugins/**", Migration::SafeMigrate.post_migration_path, "**/*.rb")] ++ Dir[Rails.root.join("plugins/**", "db/migrate/*.rb")]endprotected@@ -162,7 +164,10 @@ module BackupRestore@created_functions_for_table_columns = []all_readonly_table_columns = []- DatabaseRestorer.core_migration_files.each do |path|+ DatabaseRestorer.all_migration_files.each do |path|+ file_content = File.read(path)+ next if file_content.exclude?("DROPPED_TABLES") && file_content.exclude?("DROPPED_COLUMNS")+require pathclass_name = File.basename(path, ".rb").sub(/\A\d+_/, "").camelizemigration_class = class_name.constantizediff --git a/spec/lib/backup_restore/database_restorer_spec.rb b/spec/lib/backup_restore/database_restorer_spec.rbindex 7c04e6cb25f..50ccf3f8d18 100644--- a/spec/lib/backup_restore/database_restorer_spec.rb+++ b/spec/lib/backup_restore/database_restorer_spec.rb@@ -157,7 +157,7 @@ RSpec.describe BackupRestore::DatabaseRestorer dodescribe "readonly functions" dobefore do- BackupRestore::DatabaseRestorer.stubs(:core_migration_files).returns(+ BackupRestore::DatabaseRestorer.stubs(:all_migration_files).returns(Dir[Rails.root.join("spec/fixtures/db/post_migrate/drop_column/**/*.rb")],)end