From 91ed21b304c468db8ce9fd830312c151432935d0 Mon Sep 17 00:00:00 2001 From: Bob Lail Date: Tue, 5 Mar 2019 13:16:44 -0600 Subject: Add insert_all to ActiveRecord models (#35077) Adds a method to ActiveRecord allowing records to be inserted in bulk without instantiating ActiveRecord models. This method supports options for handling uniqueness violations by skipping duplicate records or overwriting them in an UPSERT operation. ActiveRecord already supports bulk-update and bulk-destroy actions that execute SQL UPDATE and DELETE commands directly. It also supports bulk-read actions through `pluck`. It makes sense for it also to support bulk-creation. --- activerecord/CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activerecord/CHANGELOG.md') diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 04449a3ebc..cff6a3147b 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,13 @@ +* Add `insert_all`/`insert_all!`/`upsert_all` methods to `ActiveRecord::Persistence`, + allowing bulk inserts akin to the bulk updates provided by `update_all` and + bulk deletes by `delete_all`. + + Supports skipping or upserting duplicates through the `ON CONFLICT` syntax + for Postgres (9.5+) and Sqlite (3.24+) and `ON DUPLICATE KEY UPDATE` syntax + for MySQL. + + *Bob Lail* + * Add `rails db:seed:replant` that truncates tables of each database for current environment and loads the seeds. -- cgit v1.2.3