about summary refs log tree commit diff stats
path: root/db/migrate/20170924224550_create_pokeviewer_boxes.rb
blob: 02f6fa9b5e85710dfd5b2ac6ba537ca5091894f8 (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 :pokeviewer_boxes do |t|
      t.references :trainer, null: false
      t.integer :number, null: false
      t.string :name, null: false

      t.timestamps
    end

    add_foreign_key :pokeviewer_boxes, :pokeviewer_trainer, column: :trainer_id

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