FIX: Check all migrations for dropped columns/tables during restore
Previously only post-deploy migrations were being checked for DROPPED_(COLUMNS|TABLES) constants
This commit is contained in:
parent
7e5ad9aaaa
commit
d2c5165052
|
@ -51,6 +51,11 @@ module BackupRestore
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.core_migration_files
|
||||||
|
Dir[Rails.root.join(Migration::SafeMigrate.post_migration_path, "**/*.rb")] +
|
||||||
|
Dir[Rails.root.join("db/migrate/*.rb")]
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def restore_dump
|
def restore_dump
|
||||||
|
@ -154,7 +159,7 @@ module BackupRestore
|
||||||
@created_functions_for_table_columns = []
|
@created_functions_for_table_columns = []
|
||||||
all_readonly_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 path
|
require path
|
||||||
class_name = File.basename(path, ".rb").sub(/^\d+_/, "").camelize
|
class_name = File.basename(path, ".rb").sub(/^\d+_/, "").camelize
|
||||||
migration_class = class_name.constantize
|
migration_class = class_name.constantize
|
||||||
|
|
|
@ -200,7 +200,9 @@ describe BackupRestore::DatabaseRestorer do
|
||||||
|
|
||||||
context "readonly functions" do
|
context "readonly functions" do
|
||||||
before do
|
before 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")]
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't try to drop function when no functions have been created" do
|
it "doesn't try to drop function when no functions have been created" do
|
||||||
|
|
Loading…
Reference in New Issue