From 0f32f526b73ecfd10012c0db9d7c4a4f15251a73 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 10 Oct 2017 22:46:46 -0400 Subject: Added type and ability data to species model --- .../20171011015325_create_pokeviewer_abilities.rb | 12 ++++++++++++ .../20171011015648_add_type_and_ability_to_species.rb | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 db/migrate/20171011015325_create_pokeviewer_abilities.rb create mode 100644 db/migrate/20171011015648_add_type_and_ability_to_species.rb (limited to 'db/migrate') 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 @@ +class CreatePokeviewerAbilities < ActiveRecord::Migration[5.1] + def change + create_table :pokeviewer_abilities do |t| + t.string :name, null: false, limit: 191 + t.string :description, null: false + + t.timestamps + end + + add_index :pokeviewer_abilities, :name, unique: true + end +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 @@ +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 -- cgit 1.4.1