From b6213b25e9d77baa8798bf5db258ff1be41f3384 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Mon, 20 Mar 2023 13:45:42 +1100 Subject: [PATCH] add acts_as_paranoid to voucher This is so the relation `belongs_to :originator, -> { with_deleted }, polymorphic: true` setup in Spree::Adjustement works as expected. --- app/models/voucher.rb | 2 ++ db/migrate/20230315040748_add_deleted_at_to_vouchers.rb | 6 ++++++ db/schema.rb | 2 ++ 3 files changed, 10 insertions(+) create mode 100644 db/migrate/20230315040748_add_deleted_at_to_vouchers.rb diff --git a/app/models/voucher.rb b/app/models/voucher.rb index 783c5c93aa..533b7aece2 100644 --- a/app/models/voucher.rb +++ b/app/models/voucher.rb @@ -1,6 +1,8 @@ # frozen_string_literal: false class Voucher < ApplicationRecord + acts_as_paranoid + include CalculatedAdjustments belongs_to :enterprise diff --git a/db/migrate/20230315040748_add_deleted_at_to_vouchers.rb b/db/migrate/20230315040748_add_deleted_at_to_vouchers.rb new file mode 100644 index 0000000000..d9993f2b93 --- /dev/null +++ b/db/migrate/20230315040748_add_deleted_at_to_vouchers.rb @@ -0,0 +1,6 @@ +class AddDeletedAtToVouchers < ActiveRecord::Migration[6.1] + def change + add_column :vouchers, :deleted_at, :datetime + add_index :vouchers, :deleted_at + end +end diff --git a/db/schema.rb b/db/schema.rb index dbcb97b5a1..41b3d45046 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1196,7 +1196,9 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_24_141213) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.bigint "enterprise_id" + t.datetime "deleted_at" t.index ["code", "enterprise_id"], name: "index_vouchers_on_code_and_enterprise_id", unique: true + t.index ["deleted_at"], name: "index_vouchers_on_deleted_at" t.index ["enterprise_id"], name: "index_vouchers_on_enterprise_id" end