Sha256: f85ec8b8212b3cca52457fc5b146a1cdc716261e7c1d019cfe68befcaab8aa2b

Contents?: true

Size: 592 Bytes

Versions: 3

Compression:

Stored size: 592 Bytes

Contents

# This migration comes from spree (originally 20150309161154)
class EnsurePaymentsHaveNumbers < ActiveRecord::Migration[4.2]
  def change
    add_index :spree_payments, :number unless index_exists?(:spree_payments, :number)
    Spree::Payment.where(number: nil).find_each do |payment|
      begin
        payment.save! # to generate a new number we need to save the record
      rescue ActiveRecord::RecordNotSaved
        Rails.logger.error("Payment with ID = #{payment.id} couldn't be saved")
        Rails.logger.error(payment.errors.full_messages.to_sentence)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
spree_purchase_order-3.7.0 spec/dummy/db/migrate/20191113195915_ensure_payments_have_numbers.spree.rb
spree_billing_sisow-0.9.2 spec/dummy/db/migrate/20190729091856_ensure_payments_have_numbers.spree.rb
spree_billing_sisow-0.9.1 spec/dummy/db/migrate/20190729091856_ensure_payments_have_numbers.spree.rb