Sha256: e44c185f9d5d2b4f9337266d4f73b69e0ad756facc8716aca59f3dd2d9b0e21b
Contents?: true
Size: 562 Bytes
Versions: 120
Compression:
Stored size: 562 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.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
120 entries across 120 versions & 1 rubygems