Skip to content

Commit

Permalink
Removed Cart table, its dependency on spree orders table and removed …
Browse files Browse the repository at this point in the history
…some more dead code related to this
  • Loading branch information
luisramos0 committed Aug 15, 2018
1 parent 0b9061d commit 91e57cb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 27 deletions.
14 changes: 0 additions & 14 deletions app/controllers/spree/orders_controller_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,20 +202,6 @@ def populate_variant_attributes
end
end

def populate_cart hash
if spree_current_user
unless spree_current_user.cart
spree_current_user.build_cart
cart = Cart.create(user: spree_current_user)
spree_current_user.cart = cart
spree_current_user.save
end
distributor = Enterprise.find(hash[:distributor_id])
order_cycle = OrderCycle.find(hash[:order_cycle_id]) if hash[:order_cycle_id]
spree_current_user.cart.add_variant hash[:variants].keys.first, hash[:variants].values.first, distributor, order_cycle, current_currency
end
end

# Rails to_json encodes Float::INFINITY as Infinity, which is not valid JSON
# Return it as a large integer (max 32 bit signed int)
def wrap_json_infinity(n)
Expand Down
1 change: 0 additions & 1 deletion app/models/spree/order_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
Spree::Order.class_eval do
belongs_to :order_cycle
belongs_to :distributor, class_name: 'Enterprise'
belongs_to :cart
belongs_to :customer
has_one :proxy_order
has_one :subscription, through: :proxy_order
Expand Down
1 change: 0 additions & 1 deletion app/models/spree/user_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
has_many :owned_groups, class_name: 'EnterpriseGroup', foreign_key: :owner_id, inverse_of: :owner
has_many :account_invoices
has_many :billable_periods, foreign_key: :owner_id, inverse_of: :owner
has_one :cart
has_many :customers
has_many :credit_cards

Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20180812214434_drop_carts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class DropCarts < ActiveRecord::Migration
def change
remove_foreign_key :spree_orders, column: :cart_id
remove_column :spree_orders, :cart_id
drop_table :carts
end
end
12 changes: 1 addition & 11 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20180510083800) do
ActiveRecord::Schema.define(:version => 20180812214434) do

create_table "account_invoices", :force => true do |t|
t.integer "user_id", :null => false
Expand Down Expand Up @@ -53,12 +53,6 @@

add_index "billable_periods", ["account_invoice_id"], :name => "index_billable_periods_on_account_invoice_id"

create_table "carts", :force => true do |t|
t.integer "user_id"
end

add_index "carts", ["user_id"], :name => "index_carts_on_user_id"

create_table "column_preferences", :force => true do |t|
t.integer "user_id", :null => false
t.string "action_name", :null => false
Expand Down Expand Up @@ -621,7 +615,6 @@
t.integer "order_cycle_id"
t.string "currency"
t.string "last_ip_address"
t.integer "cart_id"
t.integer "customer_id"
end

Expand Down Expand Up @@ -1203,8 +1196,6 @@
add_foreign_key "billable_periods", "enterprises", name: "bill_items_enterprise_id_fk"
add_foreign_key "billable_periods", "spree_users", name: "bill_items_owner_id_fk", column: "owner_id"

add_foreign_key "carts", "spree_users", name: "carts_user_id_fk", column: "user_id"

add_foreign_key "coordinator_fees", "enterprise_fees", name: "coordinator_fees_enterprise_fee_id_fk"
add_foreign_key "coordinator_fees", "order_cycles", name: "coordinator_fees_order_cycle_id_fk"

Expand Down Expand Up @@ -1285,7 +1276,6 @@
add_foreign_key "spree_option_values_variants", "spree_option_values", name: "spree_option_values_variants_option_value_id_fk", column: "option_value_id"
add_foreign_key "spree_option_values_variants", "spree_variants", name: "spree_option_values_variants_variant_id_fk", column: "variant_id"

add_foreign_key "spree_orders", "carts", name: "spree_orders_cart_id_fk"
add_foreign_key "spree_orders", "customers", name: "spree_orders_customer_id_fk"
add_foreign_key "spree_orders", "enterprises", name: "spree_orders_distributor_id_fk", column: "distributor_id"
add_foreign_key "spree_orders", "order_cycles", name: "spree_orders_order_cycle_id_fk"
Expand Down

0 comments on commit 91e57cb

Please sign in to comment.