File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
activerecord/lib/active_record Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 7
7
require "active_support/core_ext/enumerable"
8
8
require "active_support/core_ext/module/attribute_accessors"
9
9
require "active_support/actionable_error"
10
+ require "active_record/migration/pending_migration_connection"
10
11
11
12
module ActiveRecord
12
13
class MigrationError < ActiveRecordError # :nodoc:
@@ -768,9 +769,11 @@ def db_configs_in_current_env
768
769
def pending_migrations
769
770
pending_migrations = [ ]
770
771
771
- ActiveRecord ::Tasks ::DatabaseTasks . with_temporary_connection_for_each ( env : env ) do |connection |
772
- if pending = connection . migration_context . open . pending_migrations
773
- pending_migrations << pending
772
+ ActiveRecord ::Base . configurations . configs_for ( env_name : env ) . each do |db_config |
773
+ ActiveRecord ::PendingMigrationConnection . establish_temporary_connection ( db_config ) do |conn |
774
+ if pending = conn . migration_context . open . pending_migrations
775
+ pending_migrations << pending
776
+ end
774
777
end
775
778
end
776
779
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ class PendingMigrationConnection # :nodoc:
5
+ def self . establish_temporary_connection ( db_config , &block )
6
+ pool = ActiveRecord ::Base . connection_handler . establish_connection ( db_config , owner_name : self )
7
+
8
+ yield pool . connection
9
+ ensure
10
+ ActiveRecord ::Base . connection_handler . remove_connection_pool ( self . name )
11
+ end
12
+
13
+ def self . primary_class?
14
+ false
15
+ end
16
+
17
+ def self . current_preventing_writes
18
+ false
19
+ end
20
+ end
21
+ end
You can’t perform that action at this time.
0 commit comments