diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2017-09-12 10:08:16 +0300 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2017-10-15 22:27:54 +0300 |
commit | 678e563da3e7cddca9501ec90cdd76ee399a62b1 (patch) | |
tree | e9463d1d603ace41a0270c8a987fb4b0a3bbc625 /activerecord/lib | |
parent | 99b2bf8db39846897f017129a41efcffa840dc68 (diff) | |
download | rails-678e563da3e7cddca9501ec90cdd76ee399a62b1.tar.gz rails-678e563da3e7cddca9501ec90cdd76ee399a62b1.tar.bz2 rails-678e563da3e7cddca9501ec90cdd76ee399a62b1.zip |
`ActiveRecord::Tasks::DatabaseTasks.load_schema` has always to establish database connection
When load schema from `structure.sql`, database connection isn't
established. `ActiveRecord::Tasks::DatabaseTasks.load_schema` has to
establish database connection since it executes
```
ActiveRecord::InternalMetadata.create_table
ActiveRecord::InternalMetadata[:environment] = environment
```
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/tasks/database_tasks.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 0b85965bab..ff388ff1f6 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -228,13 +228,13 @@ module ActiveRecord def load_schema(configuration, format = ActiveRecord::Base.schema_format, file = nil, environment = env) # :nodoc: file ||= schema_file(format) + check_schema_file(file) + ActiveRecord::Base.establish_connection(configuration) + case format when :ruby - check_schema_file(file) - ActiveRecord::Base.establish_connection(configuration) load(file) when :sql - check_schema_file(file) structure_load(configuration, file) else raise ArgumentError, "unknown format #{format.inspect}" |