Sha256: ffed4668cba58d035d39897bce03e08cf60dcb617f4df71573c3c0ec2853af15

Contents?: true

Size: 603 Bytes

Versions: 22

Compression:

Stored size: 603 Bytes

Contents

class AddMakeActiveAtToSpreeProducts < ActiveRecord::Migration[5.2]
  def change
    add_column :spree_products, :make_active_at, :datetime
    add_index :spree_products, :make_active_at

    Spree::Product.
      where('discontinue_on IS NULL or discontinue_on > ?', Time.current).
      where('available_on <= ?', Time.current).
      where(status: 'draft').
      update_all(status: 'active', updated_at: Time.current)

    Spree::Product.
      where('discontinue_on <= ?', Time.current).
      where.not(status: 'archived').
      update_all(status: 'archived', updated_at: Time.current)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
spree_core-4.5.1 db/migrate/20220117100333_add_make_active_at_to_spree_products.rb
spree_core-4.5.0 db/migrate/20220117100333_add_make_active_at_to_spree_products.rb