Skip to content

Commit bd16ad7

Browse files
committed
Cleanup rails#53666
* Fix style * Fix documentation * Use fetch like the other methods
1 parent b80bc2f commit bd16ad7

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

activerecord/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
* Allow setting `schema_format` in database configuration.
1+
* Allow setting the `schema_format` via database configuration.
22

33
```
44
primary:
55
schema_format: ruby
66
```
77
8-
Useful in multi-database setups to have different formats per-database.
8+
Useful for multi-database setups when apps require different formats per-database.
99
1010
*T S Vallender*
1111

activerecord/lib/active_record/database_configurations/hash_config.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ def schema_dump(format = schema_format)
159159
end
160160

161161
def schema_format # :nodoc:
162-
format = configuration_hash[:schema_format]&.to_sym || ActiveRecord.schema_format
163-
raise "Invalid schema format" unless [ :ruby, :sql ].include? format
162+
format = configuration_hash.fetch(:schema_format, ActiveRecord.schema_format).to_sym
163+
raise "Invalid schema format" unless [:ruby, :sql].include?(format)
164164
format
165165
end
166166

activerecord/lib/active_record/railties/databases.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ db_namespace = namespace :db do
459459

460460
namespace :dump do
461461
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
462-
desc "Create a database schema file (either db/schema.rb or db/structure.sql, depending on `ENV['SCHEMA_FORMAT']` or `config.active_record.schema_format`) for #{name} database"
462+
desc "Create a database schema file (either db/schema.rb or db/structure.sql, depending on configuration) for #{name} database"
463463
task name => :load_config do
464464
ActiveRecord::Tasks::DatabaseTasks.with_temporary_pool_for_each(name: name) do |pool|
465465
db_config = pool.db_config

0 commit comments

Comments
 (0)