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

Version Path
solidus_core-1.4.2 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.3.2 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.4.1 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.4.0 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.4.0.rc1 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.4.0.beta1 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.3.1 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.3.0 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.3.0.rc2 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.3.0.rc1 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.3.0.beta1 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb