diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20180129213822_create_pokeviewer_pokedex_entries.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/db/migrate/20180129213822_create_pokeviewer_pokedex_entries.rb b/db/migrate/20180129213822_create_pokeviewer_pokedex_entries.rb new file mode 100644 index 0000000..99ac4f6 --- /dev/null +++ b/db/migrate/20180129213822_create_pokeviewer_pokedex_entries.rb | |||
@@ -0,0 +1,20 @@ | |||
1 | class CreatePokeviewerPokedexEntries < ActiveRecord::Migration[5.1] | ||
2 | def change | ||
3 | create_table :pokeviewer_pokedex_entries do |t| | ||
4 | t.references :trainer, null: true | ||
5 | t.references :species, null: true | ||
6 | t.boolean :caught, null: true, default: false | ||
7 | |||
8 | t.timestamps | ||
9 | end | ||
10 | |||
11 | add_foreign_key :pokeviewer_pokedex_entries, :pokeviewer_trainer, | ||
12 | column: :trainer_id | ||
13 | |||
14 | add_foreign_key :pokeviewer_pokedex_entries, :pokeviewer_species, | ||
15 | column: :species_id | ||
16 | |||
17 | add_index :pokeviewer_pokedex_entries, [:trainer_id, :species_id], | ||
18 | unique: true | ||
19 | end | ||
20 | end | ||