Sha256: 5ed0cb69bbe7ce7b7e3aa99a59282f4cd3de7b5bb9a0b0461d06e0e50eba7c79
Contents?: true
Size: 558 Bytes
Versions: 76
Compression:
Stored size: 558 Bytes
Contents
class CopyProductSlugsToSlugHistory < ActiveRecord::Migration 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}', #{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
76 entries across 76 versions & 2 rubygems