Skip to content

Commit

Permalink
Move Line Item Actions to solidus_legacy_promotions
Browse files Browse the repository at this point in the history
This table belongs to the legacy promotion system and was,
unfortunately, missed in the original extraction.

(cherry picked from commit d339e84)
  • Loading branch information
mamhoff committed Nov 14, 2024
1 parent 4b5beac commit 9e4e06e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
3 changes: 0 additions & 3 deletions core/app/models/spree/line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ class LineItem < Spree::Base
has_many :adjustments, as: :adjustable, inverse_of: :adjustable, dependent: :destroy
has_many :inventory_units, inverse_of: :line_item

has_many :line_item_actions, dependent: :destroy
has_many :actions, through: :line_item_actions

before_validation :normalize_quantity
before_validation :set_required_attributes

Expand Down
10 changes: 0 additions & 10 deletions core/db/migrate/20160101010000_solidus_one_four.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,6 @@ def up
t.index ["variant_id"], name: "index_inventory_units_on_variant_id"
end

create_table "spree_line_item_actions", force: :cascade do |t|
t.integer "line_item_id", null: false
t.integer "action_id", null: false
t.integer "quantity", default: 0
t.datetime "created_at", precision: 6
t.datetime "updated_at", precision: 6
t.index ["action_id"], name: "index_spree_line_item_actions_on_action_id"
t.index ["line_item_id"], name: "index_spree_line_item_actions_on_line_item_id"
end

create_table "spree_line_items", force: :cascade do |t|
t.integer "variant_id"
t.integer "order_id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

module SolidusLegacyPromotions
module SpreeLineItemDecorator
def self.prepended(base)
base.has_many :line_item_actions, dependent: :destroy
base.has_many :actions, through: :line_item_actions
end

def total_before_tax
amount + adjustments.select { |value| !value.tax? && value.eligible? }.sum(&:amount)
end
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,17 @@ def up
t.index ["starts_at"], name: "index_spree_promotions_on_starts_at"
end
end

unless table_exists?(:spree_line_item_actions)
create_table "spree_line_item_actions", force: :cascade do |t|
t.integer "line_item_id", null: false
t.integer "action_id", null: false
t.integer "quantity", default: 0
t.datetime "created_at", precision: 6
t.datetime "updated_at", precision: 6
t.index ["action_id"], name: "index_spree_line_item_actions_on_action_id"
t.index ["line_item_id"], name: "index_spree_line_item_actions_on_line_item_id"
end
end
end
end

0 comments on commit 9e4e06e

Please sign in to comment.