Sha256: 598dbbcad948ba23eb072afb975e6d30ff791e79988a0665726ccd0fd2f88359
Contents?: true
Size: 553 Bytes
Versions: 11
Compression:
Stored size: 553 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}', #{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
11 entries across 11 versions & 1 rubygems