Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Credit Card model drop DB connection check for paranoia as it's not reliable (#11224)

Damian Legawiec5165564429d3
diff --git a/core/app/models/spree/credit_card.rb b/core/app/models/spree/credit_card.rb
index 77ead76802..ece8d9a65d 100644
--- a/core/app/models/spree/credit_card.rb
+++ b/core/app/models/spree/credit_card.rb
@@ -2,13 +2,7 @@ module Spree
class CreditCard < Spree::Base
include ActiveMerchant::Billing::CreditCardMethods
- # to migrate safely from older Spree versions that din't provide safe deletion for CCs
- # we need to ensure that we have a connection to the DB and that the `deleted_at` column exists
- if !ENV['SPREE_DISABLE_DB_CONNECTION'] &&
- table_exists? &&
- connection.column_exists?(:spree_credit_cards, :deleted_at)
- acts_as_paranoid
- end
+ acts_as_paranoid
belongs_to :payment_method
belongs_to :user, class_name: Spree.user_class.to_s, foreign_key: 'user_id',
diff --git a/core/db/migrate/20140805171219_make_existing_credit_cards_default.rb b/core/db/migrate/20140805171219_make_existing_credit_cards_default.rb
deleted file mode 100644
index 4d50d96f96..0000000000
--- a/core/db/migrate/20140805171219_make_existing_credit_cards_default.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class MakeExistingCreditCardsDefault < ActiveRecord::Migration[4.2]
- def up
- # set the newest credit card for every user to be the default; SQL technique from
- # http://stackoverflow.com/questions/121387/fetch-the-row-which-has-the-max-value-for-a-column
- Spree::CreditCard.where.not(user_id: nil).joins("LEFT OUTER JOIN spree_credit_cards cc2 ON cc2.user_id = spree_credit_cards.user_id AND spree_credit_cards.created_at < cc2.created_at").where("cc2.user_id IS NULL").update_all(default: true)
- end
- def down
- # do nothing
- end
-end