handle chip and chip values operations

This commit is contained in:
Bilal
2020-09-04 04:07:43 +03:00
parent 6a1920caf3
commit 99e8b9c6f2
8 changed files with 197 additions and 4 deletions

View File

@@ -0,0 +1,12 @@
class CreateChips < ActiveRecord::Migration[5.2]
def change
create_table :chips do |t|
t.text :name, null: false
t.text :symbol, null: false
t.boolean :enabled, default: true
t.timestamps
end
add_index :chips, :name, unique: true
end
end

View File

@@ -0,0 +1,12 @@
class CreateChipValues < ActiveRecord::Migration[5.2]
def change
create_table :chip_values do |t|
t.references :base_chip, foreign_key: { to_table: :chips }
t.references :secondary_chip, foreign_key: { to_table: :chips }
t.decimal :value, precision: 12, scale: 3, null: false
t.timestamps
t.index [:base_chip_id, :secondary_chip_id], unique: true
end
end
end