about summary refs log tree commit diff stats
path: root/db/migrate/20171011015648_add_type_and_ability_to_species.rb
blob: d7d274e3135aa96b42e17e640b4a2aee180a3b2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class AddTypeAndAbilityToSpecies < ActiveRecord::Migration[5.1]
  def change
    change_table :pokeviewer_species do |t|
      t.string :type_1, null: false, default: ""
      t.string :type_2
      t.integer :ability_1_id, null: false, default: 0
      t.integer :ability_2_id
    end

    change_column_default :pokeviewer_species, :type_1, nil
    change_column_default :pokeviewer_species, :ability_1_id, nil

    add_foreign_key :pokeviewer_species, :pokeviewer_abilities,
      column: :ability_1_id

    add_foreign_key :pokeviewer_species, :pokeviewer_abilities,
      column: :ability_2_id
  end
end