Soft-delete enterprise fees

These objects can hold critical information related to adjustments and tax categories. If they are hard-deleted we lose vital data that's needed by associated records.
This commit is contained in:
Matt-Yorkley
2021-01-15 14:41:59 +00:00
parent b84fb5814e
commit c4a8a38c8d
3 changed files with 9 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
class EnterpriseFee < ActiveRecord::Base
include Spree::Core::CalculatedAdjustments
acts_as_paranoid
belongs_to :enterprise
belongs_to :tax_category, class_name: 'Spree::TaxCategory', foreign_key: 'tax_category_id'

View File

@@ -0,0 +1,5 @@
class AddDeletedAtToEnterpriseFee < ActiveRecord::Migration
def change
add_column :enterprise_fees, :deleted_at, :datetime
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20201219120055) do
ActiveRecord::Schema.define(version: 20210115143738) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -108,6 +108,7 @@ ActiveRecord::Schema.define(version: 20201219120055) do
t.datetime "updated_at", null: false
t.integer "tax_category_id"
t.boolean "inherits_tax_category", default: false, null: false
t.datetime "deleted_at"
end
add_index "enterprise_fees", ["enterprise_id"], name: "index_enterprise_fees_on_enterprise_id", using: :btree