2022-01-13 00:13:50 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AddRepositoryStockManagement < ActiveRecord::Migration[6.1]
|
|
|
|
def change
|
|
|
|
create_table :repository_stock_values do |t|
|
|
|
|
t.decimal :amount, index: true
|
2022-01-26 00:48:45 +08:00
|
|
|
t.references :repository_stock_unit_item, index: true, foreign_key: true
|
|
|
|
t.string :type
|
2022-01-13 00:13:50 +08:00
|
|
|
t.references :last_modified_by, index: true, foreign_key: { to_table: :users }
|
|
|
|
t.references :created_by, index: true, foreign_key: { to_table: :users }
|
|
|
|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
2022-01-20 19:44:57 +08:00
|
|
|
create_table :repository_ledger_records do |t|
|
|
|
|
t.references :repository_stock_value, null: false, index: true, foreign_key: true
|
|
|
|
t.references :reference, polymorphic: true, null: false
|
|
|
|
t.decimal :amount
|
|
|
|
t.decimal :balance
|
|
|
|
t.references :user, null: true
|
|
|
|
t.text :comment
|
|
|
|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
2022-01-13 00:13:50 +08:00
|
|
|
add_column :my_module_repository_rows, :stock_consumption, :decimal
|
2022-01-26 00:48:45 +08:00
|
|
|
add_reference :my_module_repository_rows,
|
|
|
|
:repository_stock_unit_item,
|
|
|
|
index: { name: 'index_on_repository_stock_unit_item_id' },
|
|
|
|
foreign_key: true
|
2022-01-13 00:13:50 +08:00
|
|
|
end
|
|
|
|
end
|