diff options
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20171011015325_create_pokeviewer_abilities.rb | 12 | ||||
-rw-r--r-- | db/migrate/20171011015648_add_type_and_ability_to_species.rb | 19 |
2 files changed, 31 insertions, 0 deletions
diff --git a/db/migrate/20171011015325_create_pokeviewer_abilities.rb b/db/migrate/20171011015325_create_pokeviewer_abilities.rb new file mode 100644 index 0000000..a7f6b5f --- /dev/null +++ b/db/migrate/20171011015325_create_pokeviewer_abilities.rb | |||
@@ -0,0 +1,12 @@ | |||
1 | class CreatePokeviewerAbilities < ActiveRecord::Migration[5.1] | ||
2 | def change | ||
3 | create_table :pokeviewer_abilities do |t| | ||
4 | t.string :name, null: false, limit: 191 | ||
5 | t.string :description, null: false | ||
6 | |||
7 | t.timestamps | ||
8 | end | ||
9 | |||
10 | add_index :pokeviewer_abilities, :name, unique: true | ||
11 | end | ||
12 | end | ||
diff --git a/db/migrate/20171011015648_add_type_and_ability_to_species.rb b/db/migrate/20171011015648_add_type_and_ability_to_species.rb new file mode 100644 index 0000000..d7d274e --- /dev/null +++ b/db/migrate/20171011015648_add_type_and_ability_to_species.rb | |||
@@ -0,0 +1,19 @@ | |||
1 | class AddTypeAndAbilityToSpecies < ActiveRecord::Migration[5.1] | ||
2 | def change | ||
3 | change_table :pokeviewer_species do |t| | ||
4 | t.string :type_1, null: false, default: "" | ||
5 | t.string :type_2 | ||
6 | t.integer :ability_1_id, null: false, default: 0 | ||
7 | t.integer :ability_2_id | ||
8 | end | ||
9 | |||
10 | change_column_default :pokeviewer_species, :type_1, nil | ||
11 | change_column_default :pokeviewer_species, :ability_1_id, nil | ||
12 | |||
13 | add_foreign_key :pokeviewer_species, :pokeviewer_abilities, | ||
14 | column: :ability_1_id | ||
15 | |||
16 | add_foreign_key :pokeviewer_species, :pokeviewer_abilities, | ||
17 | column: :ability_2_id | ||
18 | end | ||
19 | end | ||