about summary refs log tree commit diff stats
path: root/db/migrate/20180130021851_create_pokeviewer_pokedex_entries.pokeviewer.rb
blob: 2451ef2a1a8a924893f0e6f2c2e01a353fb1e24a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# This migration comes from pokeviewer (originally 20180129213822)
class CreatePokeviewerPokedexEntries < ActiveRecord::Migration[5.1]
  def change
    create_table :pokeviewer_pokedex_entries do |t|
      t.references :trainer, null: true
      t.references :species, null: true
      t.boolean :caught, null: true, default: false

      t.timestamps
    end

    add_foreign_key :pokeviewer_pokedex_entries, :pokeviewer_trainers,
      column: :trainer_id

    add_foreign_key :pokeviewer_pokedex_entries, :pokeviewer_species,
      column: :species_id

    add_index :pokeviewer_pokedex_entries, [:trainer_id, :species_id],
      unique: true
  end
end