Skip to content

Commit a2cb0b2

Browse files
authored
Merge pull request rails#42769 from Shopify/rails-7-default-partial-inserts
Disable Active Record partial_inserts by default in Rails 7.0
2 parents 02b7746 + 9108273 commit a2cb0b2

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)