A platform for community discussion. Free, open, simple.
FIX: Check all migrations for dropped columns/tables during restore
David Taylord2c5165052fd
diff --git a/lib/backup_restore/database_restorer.rb b/lib/backup_restore/database_restorer.rbindex 100a366cd9e..ae3ac7deaa4 100644--- a/lib/backup_restore/database_restorer.rb+++ b/lib/backup_restore/database_restorer.rb@@ -51,6 +51,11 @@ module BackupRestoreendend+ def self.core_migration_files+ Dir[Rails.root.join(Migration::SafeMigrate.post_migration_path, "**/*.rb")] ++ Dir[Rails.root.join("db/migrate/*.rb")]+ end+protecteddef restore_dump@@ -154,7 +159,7 @@ module BackupRestore@created_functions_for_table_columns = []all_readonly_table_columns = []- Dir[Rails.root.join(Migration::SafeMigrate.post_migration_path, "**/*.rb")].each do |path|+ DatabaseRestorer.core_migration_files.each do |path|require pathclass_name = File.basename(path, ".rb").sub(/^\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 351406e1e30..fbe6204609a 100644--- a/spec/lib/backup_restore/database_restorer_spec.rb+++ b/spec/lib/backup_restore/database_restorer_spec.rb@@ -200,7 +200,9 @@ describe BackupRestore::DatabaseRestorer docontext "readonly functions" dobefore do- Migration::SafeMigrate.stubs(:post_migration_path).returns("spec/fixtures/db/post_migrate/drop_column")+ BackupRestore::DatabaseRestorer.stubs(:core_migration_files).returns(+ Dir[Rails.root.join("spec/fixtures/db/post_migrate/drop_column/**/*.rb")]+ )endit "doesn't try to drop function when no functions have been created" do