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

Version Path
solidus_core-1.0.3 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.1.1 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.1.0 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.1.0.pre2 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.1.0.pre1 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.1.0.beta1 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.0.2 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
spree_core-3.0.4 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
spree_core-2.4.10 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.0.1 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.0.0 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.0.0.rc2 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.0.0.rc1 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
spree_core-3.0.3 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
spree_core-2.4.9 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.0.0.pre3 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.0.0.pre2 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
spree_core-3.0.2 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
spree_core-2.4.8 db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb
solidus_core-1.0.0.pre db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb