Skip to content

Commit 9108273

Browse files
committed
Disable Active Record partial_inserts by default in Rails 7.0
Ref: rails#42355 The justification for `partial_inserts` back in 2012 (144e869) was: > This is more efficient, and also means that it will be safe to remove > database columns without getting subsequent errors in running app processes > (so long as the code in those processes doesn't contain any references to the > removed column). But since then `ignored_columns` is a much more reliable way to safely remove a column, and I doubt the reduced query size really help much. Additionally, `partial_inserts` prevent removing the default value of a column in a safe way.
1 parent 02b7746 commit 9108273

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

activerecord/CHANGELOG.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1+
* `partial_inserts` is now disabled by default in new apps.
2+
3+
This will be the default for new apps in Rails 7. To opt in:
4+
5+
```ruby
6+
config.active_record.partial_inserts = false
7+
```
8+
9+
If a migration remove the default value of a column, this option
10+
would cause old processes to no longer be able to create new records.
11+
12+
If you need to remove a column, you should first use `ignored_columns`
13+
to stop using it.
14+
15+
*Jean Boussier*
16+
117
* Rails can now verify foreign keys after loading fixtures in tests.
218

319
This will be the default for new apps in Rails 7. To opt in:
4-
20+
521
```ruby
622
config.active_record.verify_foreign_keys_for_fixtures = true
723
```
8-
24+
925
Tests will not run if there is a foreign key constraint violation in your fixture data.
1026

1127
The feature is supported by SQLite and PostgreSQL, other adapters can also add support for it.

railties/lib/rails/application/configuration.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ def load_defaults(target_version)
229229

230230
if respond_to?(:active_record)
231231
active_record.verify_foreign_keys_for_fixtures = true
232+
active_record.partial_inserts = false
232233
end
233234
else
234235
raise "Unknown version #{target_version.to_s.inspect}"

0 commit comments

Comments
 (0)