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/test/schema/schema.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/test/schema/schema.rb') diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index 5d46bd47d9..ead4de2a13 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -114,6 +114,10 @@ ActiveRecord::Schema.define do t.column :font_size, :integer, **default_zero t.column :difficulty, :integer, **default_zero t.column :cover, :string, default: "hard" + t.string :isbn + t.datetime :published_on + t.index [:author_id, :name], unique: true + t.index :isbn, where: "published_on IS NOT NULL", unique: true end create_table :booleans, force: true do |t| -- cgit v1.2.3