Permalink
Browse files

Allow schema/structure load for multiple databases

Pass the spec name to load_schema in order to load from the correct
structure file when there are multiple databases
  • Loading branch information...
eileencodes committed Apr 6, 2018
1 parent ab43b54 commit 48d58494dbfaab759531c168f0103542e4f73614
Showing with 3 additions and 3 deletions.
  1. +3 −3 activerecord/lib/active_record/tasks/database_tasks.rb
@@ -240,8 +240,8 @@ def structure_load(*arguments)
class_for_adapter(configuration["adapter"]).new(*arguments).structure_load(filename, structure_load_flags)
end
def load_schema(configuration, format = ActiveRecord::Base.schema_format, file = nil, environment = env) # :nodoc:
file ||= schema_file(format)
def load_schema(configuration, format = ActiveRecord::Base.schema_format, file = nil, environment = env, spec_name = "primary") # :nodoc:
file ||= dump_filename(spec_name, format)
check_schema_file(file)
ActiveRecord::Base.establish_connection(configuration)
@@ -283,7 +283,7 @@ def dump_filename(namespace, format = ActiveRecord::Base.schema_format)
def load_schema_current(format = ActiveRecord::Base.schema_format, file = nil, environment = env)
each_current_configuration(environment) { |configuration, spec_name, env|
load_schema configuration, format, file, env
load_schema(configuration, format, file, env, spec_name)
}
ActiveRecord::Base.establish_connection(environment.to_sym)
end

0 comments on commit 48d5849

Please sign in to comment.