class CreatePokeviewerPokedexEntries < ActiveRecord::Migration[5.1] def change create_table :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 :pokedex_entries, :trainers, column: :trainer_id add_foreign_key :pokedex_entries, :species, column: :species_id add_index :pokedex_entries, [:trainer_id, :species_id], unique: true end end