diff --git a/core/db/migrate/20160101010000_solidus_one_four.rb b/core/db/migrate/20160101010000_solidus_one_four.rb index a7a910c23fd..99c69eaa325 100644 --- a/core/db/migrate/20160101010000_solidus_one_four.rb +++ b/core/db/migrate/20160101010000_solidus_one_four.rb @@ -90,14 +90,12 @@ def up t.datetime "updated_at", precision: 6 t.integer "order_id", null: false t.boolean "included", default: false - t.integer "promotion_code_id" t.integer "adjustment_reason_id" t.boolean "finalized", default: false, null: false t.index ["adjustable_id", "adjustable_type"], name: "index_spree_adjustments_on_adjustable_id_and_adjustable_type" t.index ["adjustable_id"], name: "index_adjustments_on_order_id" t.index ["eligible"], name: "index_spree_adjustments_on_eligible" t.index ["order_id"], name: "index_spree_adjustments_on_order_id" - t.index ["promotion_code_id"], name: "index_spree_adjustments_on_promotion_code_id" t.index ["source_id", "source_type"], name: "index_spree_adjustments_on_source_id_and_source_type" end diff --git a/legacy_promotions/db/migrate/20240621100123_add_promotion_code_id_to_spree_adjustments.rb b/legacy_promotions/db/migrate/20240621100123_add_promotion_code_id_to_spree_adjustments.rb new file mode 100644 index 00000000000..069cb9f5821 --- /dev/null +++ b/legacy_promotions/db/migrate/20240621100123_add_promotion_code_id_to_spree_adjustments.rb @@ -0,0 +1,10 @@ +class AddPromotionCodeIdToSpreeAdjustments < ActiveRecord::Migration[5.0] + def up + unless column_exists?(:spree_adjustments, :promotion_code_id) + add_column :spree_adjustments, :promotion_code_id, :integer + end + unless index_exists?(:spree_adjustments, :promotion_code_id) + add_index :spree_adjustments, :promotion_code_id, name: "index_spree_adjustments_on_promotion_code_id" + end + end +end diff --git a/legacy_promotions/spec/models/spree/adjustment_spec.rb b/legacy_promotions/spec/models/spree/adjustment_spec.rb index 48596f5f03d..eb2e1b5380b 100644 --- a/legacy_promotions/spec/models/spree/adjustment_spec.rb +++ b/legacy_promotions/spec/models/spree/adjustment_spec.rb @@ -9,6 +9,7 @@ let(:adjustment) { Spree::Adjustment.create!(label: 'Adjustment', adjustable: order, order: order, amount: 5) } + it { is_expected.to respond_to(:promotion_code) } context '#recalculate' do subject { adjustment.recalculate } let(:adjustment) do