Sha256: ba7ea32fbd3f5d087a1c66dbfd12540aac47bcac77873bf4b0c0d33d6d227b80
Contents?: true
Size: 558 Bytes
Versions: 21
Compression:
Stored size: 558 Bytes
Contents
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}', #{ActiveRecord::Base.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
21 entries across 21 versions & 1 rubygems