Add versions table/model for prices

This commit is contained in:
Alex Sherman 2020-09-10 15:55:30 +05:00
parent e03ae63acf
commit 86ea2319c8
5 changed files with 92 additions and 16 deletions

View file

@ -1,6 +0,0 @@
class RemovePaperTrailColumnsFromPrices < ActiveRecord::Migration
def change
remove_column :prices, :creator_str
remove_column :prices, :updator_str
end
end

View file

@ -0,0 +1,26 @@
class CreateVersionForPrices < ActiveRecord::Migration[6.0]
def up
create_table :log_prices, force: :cascade do |t|
t.string :item_type, null: false
t.integer :item_id, null: false
t.string :event, null: false
t.string :whodunnit
t.json :object
t.json :object_changes
t.datetime :created_at
t.string :session
t.json :children
t.string :uuid
end
add_index 'log_prices', ['item_type', 'item_id'], name: 'index_log_prices_on_item_type_and_item_id', using: :btree
add_index 'log_prices', ['whodunnit'], name: 'index_log_prices_on_whodunnit', using: :btree
end
def down
remove_index :log_prices, name: 'index_log_prices_on_item_type_and_item_id'
remove_index :log_prices, name: 'index_log_prices_on_whodunnit'
drop_table :log_prices
end
end