Skip to content

Commit 7cb7cb8

Browse files
authored
Merge pull request rails#52608 from kirs/extract-load-schema
Split AR::Migration.load_schema_if_pending! into two methods
2 parents 5ec96d9 + 1205943 commit 7cb7cb8

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

activerecord/lib/active_record/migration.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -715,13 +715,7 @@ def check_all_pending!
715715

716716
def load_schema_if_pending!
717717
if any_schema_needs_update?
718-
# Roundtrip to Rake to allow plugins to hook into database initialization.
719-
root = defined?(ENGINE_ROOT) ? ENGINE_ROOT : Rails.root
720-
721-
FileUtils.cd(root) do
722-
Base.connection_handler.clear_all_connections!(:all)
723-
system("bin/rails db:test:prepare")
724-
end
718+
load_schema!
725719
end
726720

727721
check_pending_migrations
@@ -785,6 +779,16 @@ def pending_migrations
785779
def env
786780
ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
787781
end
782+
783+
def load_schema!
784+
# Roundtrip to Rake to allow plugins to hook into database initialization.
785+
root = defined?(ENGINE_ROOT) ? ENGINE_ROOT : Rails.root
786+
787+
FileUtils.cd(root) do
788+
Base.connection_handler.clear_all_connections!(:all)
789+
system("bin/rails db:test:prepare")
790+
end
791+
end
788792
end
789793

790794
def disable_ddl_transaction # :nodoc:

0 commit comments

Comments
 (0)