Sha256: c04d34538643158b9dee1e3f705317c4872c493cf5bd1a974419fe70aec0112f
Contents?: true
Size: 624 Bytes
Versions: 9
Compression:
Stored size: 624 Bytes
Contents
# This migration comes from spree (originally 20140723214541) class CopyProductSlugsToSlugHistory < ActiveRecord::Migration[4.2] def change # do what sql does best: copy all slugs into history table in a single query # rather than load potentially millions of products into memory Spree::Product.connection.execute <<-SQL INSERT INTO #{FriendlyId::Slug.table_name} (slug, sluggable_id, sluggable_type, created_at) SELECT slug, id, '#{Spree::Product.to_s}', #{ApplicationRecord.send(:sanitize_sql_array, ['?', Time.current])} FROM #{Spree::Product.table_name} WHERE slug IS NOT NULL ORDER BY id SQL end end
Version data entries
9 entries across 9 versions & 2 rubygems