From 0bfb8ae3ec6348664c4625df89b252193aa14725 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 13 Jan 2018 16:19:36 -0500 Subject: Actually added migration from previous commit --- ...13211911_move_species_to_revision.pokeviewer.rb | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 db/migrate/20180113211911_move_species_to_revision.pokeviewer.rb (limited to 'db/migrate') diff --git a/db/migrate/20180113211911_move_species_to_revision.pokeviewer.rb b/db/migrate/20180113211911_move_species_to_revision.pokeviewer.rb new file mode 100644 index 0000000..bd19f21 --- /dev/null +++ b/db/migrate/20180113211911_move_species_to_revision.pokeviewer.rb @@ -0,0 +1,40 @@ +# This migration comes from pokeviewer (originally 20180113200119) +class MoveSpeciesToRevision < ActiveRecord::Migration[5.1] + def up + change_table :pokeviewer_revisions do |t| + t.references :species, null: true + end + + Pokeviewer::Revision.all.each do |r| + r.species_id = r.pokemon.species_id + r.save! + end + + remove_column :pokeviewer_pokemon, :species_id + + change_column_null :pokeviewer_revisions, :species_id, false + + add_foreign_key :pokeviewer_revisions, :pokeviewer_species, + column: :species_id + end + + def down + def up + change_table :pokeviewer_pokemon do |t| + t.references :species, null: true + end + + Pokeviewer::Pokemon.all.each do |p| + p.species_id = p.revisions.first.species_id + p.save! + end + + remove_column :pokeviewer_revisions, :species_id + + change_column_null :pokeviewer_pokemon, :species_id, false + + add_foreign_key :pokeviewer_pokemon, :pokeviewer_species, + column: :species_id + end + end +end -- cgit 1.4.1