Sha256: eeef19885277e9f6959f9989b09b3c88888158406dc14fbb603dd2b9113d0aeb

Contents?: true

Size: 1020 Bytes

Versions: 5

Compression:

Stored size: 1020 Bytes

Contents

class RenameSolidusPaypalBraintreeSourceType < ActiveRecord::Migration[6.1]
  # This is based on the best practices recommended in
  # https://github.com/ankane/strong_migrations#backfilling-data on how to
  # safely update a table.

  disable_ddl_transaction!

  def up
    Spree::Payment.unscoped
      .where(source_type: 'SolidusPaypalBraintree::Source').in_batches do |relation|
        relation.update_all("source_type = 'SolidusBraintree::Source'")
        sleep(0.01)
      end

    Spree::WalletPaymentSource.unscoped
      .where(payment_source_type: 'SolidusPaypalBraintree::Source').in_batches do |relation|
        relation.update_all("payment_source_type = 'SolidusBraintree::Source'")
        sleep(0.01)
      end

    Spree::PaymentMethod.unscoped
      .where('type = ?', 'SolidusPaypalBraintree::Gateway').in_batches do |relation|
        relation.update_all("type = 'SolidusBraintree::Gateway'")
        sleep(0.01)
      end
  end

  def down
    raise ActiveRecord::IrreversibleMigration
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_braintree-3.2.0 db/migrate/20230109080950_rename_solidus_paypal_braintree_source_type.rb
solidus_braintree-3.1.0 db/migrate/20230109080950_rename_solidus_paypal_braintree_source_type.rb
solidus_braintree-3.0.1 db/migrate/20230109080950_rename_solidus_paypal_braintree_source_type.rb
solidus_braintree-3.0.0 db/migrate/20230109080950_rename_solidus_paypal_braintree_source_type.rb
solidus_braintree-2.0.0 db/migrate/20230109080950_rename_solidus_paypal_braintree_source_type.rb