Sha256: c04d34538643158b9dee1e3f705317c4872c493cf5bd1a974419fe70aec0112f

Contents?: true

Size: 624 Bytes

Versions: 9

Compression:

Stored size: 624 Bytes

Contents

# This migration comes from spree (originally 20140723214541)
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

9 entries across 9 versions & 2 rubygems

Version Path
spree_purchase_order-3.7.0 spec/dummy/db/migrate/20191113195877_copy_product_slugs_to_slug_history.spree.rb
spree_billing_sisow-0.9.2 spec/dummy/db/migrate/20190729091818_copy_product_slugs_to_slug_history.spree.rb
spree_billing_sisow-0.9.1 spec/dummy/db/migrate/20190729091818_copy_product_slugs_to_slug_history.spree.rb
spree_purchase_order-3.6.0 spec/dummy/db/migrate/20180516182006_copy_product_slugs_to_slug_history.spree.rb
spree_purchase_order-3.5.0 spec/dummy/db/migrate/20180516182006_copy_product_slugs_to_slug_history.spree.rb
spree_purchase_order-3.5.0.rc1 spec/dummy/db/migrate/20180516182006_copy_product_slugs_to_slug_history.spree.rb
spree_purchase_order-3.4.0 spec/dummy/db/migrate/20180516182006_copy_product_slugs_to_slug_history.spree.rb
spree_purchase_order-3.3.0 spec/dummy/db/migrate/20180516182006_copy_product_slugs_to_slug_history.spree.rb
spree_purchase_order-3.2.0 spec/dummy/db/migrate/20180516182006_copy_product_slugs_to_slug_history.spree.rb