diff --git a/app/models/order_cycle.rb b/app/models/order_cycle.rb index 9a30c493e5..e9afe06e5a 100644 --- a/app/models/order_cycle.rb +++ b/app/models/order_cycle.rb @@ -17,6 +17,7 @@ class OrderCycle < ActiveRecord::Base has_many :distributors, source: :receiver, through: :cached_outgoing_exchanges, uniq: true has_and_belongs_to_many :schedules, join_table: 'order_cycle_schedules' + has_paper_trail meta: { custom_data: :schedule_ids } attr_accessor :incoming_exchanges, :outgoing_exchanges diff --git a/app/models/schedule.rb b/app/models/schedule.rb index 67443f7784..1f8c5b9b3a 100644 --- a/app/models/schedule.rb +++ b/app/models/schedule.rb @@ -1,5 +1,7 @@ class Schedule < ActiveRecord::Base has_and_belongs_to_many :order_cycles, join_table: 'order_cycle_schedules' + has_paper_trail meta: { custom_data: :order_cycle_ids } + has_many :coordinators, uniq: true, through: :order_cycles attr_accessible :name, :order_cycle_ids diff --git a/config/initializers/paper_trail.rb b/config/initializers/paper_trail.rb index 39a6679176..e955bac9be 100644 --- a/config/initializers/paper_trail.rb +++ b/config/initializers/paper_trail.rb @@ -1 +1,7 @@ PaperTrail.config.track_associations = false + +module PaperTrail + class Version < ActiveRecord::Base + attr_accessible :custom_data + end +end diff --git a/db/migrate/20191202165700_add_custom_data_to_versions.rb b/db/migrate/20191202165700_add_custom_data_to_versions.rb new file mode 100644 index 0000000000..45a10ed67e --- /dev/null +++ b/db/migrate/20191202165700_add_custom_data_to_versions.rb @@ -0,0 +1,5 @@ +class AddCustomDataToVersions < ActiveRecord::Migration + def change + add_column :versions, :custom_data, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 288c838266..03550d3930 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1202,6 +1202,7 @@ ActiveRecord::Schema.define(:version => 20191023172424) do t.string "whodunnit" t.text "object" t.datetime "created_at" + t.string "custom_data" end add_index "versions", ["item_type", "item_id"], :name => "index_versions_on_item_type_and_item_id"