about summary refs log tree commit diff stats
path: root/db/migrate/20170924224550_create_pokeviewer_boxes.rb
blob: 7a100c391e7c05e8c7aafba527755f58f03f6507 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class CreatePokeviewerBoxes < ActiveRecord::Migration[5.1]
  def change
    create_table :boxes do |t|
      t.references :trainer, null: false
      t.integer :number, null: false
      t.string :name, null: false

      t.timestamps
    end

    add_foreign_key :boxes, :trainers, column: :trainer_id

    add_index :boxes, [:trainer_id, :number], unique: true
  end
end