From 62ffd6ca978159889a87dfe4321c1c790f9108b6 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 14 Jan 2018 13:18:29 -0500 Subject: Added migration from previous pokeviewer update --- ...1813_cache_current_pokemon_revision.pokeviewer.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb (limited to 'db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb') diff --git a/db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb b/db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb new file mode 100644 index 0000000..e8f15a8 --- /dev/null +++ b/db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb @@ -0,0 +1,20 @@ +# This migration comes from pokeviewer (originally 20180114170238) +class CacheCurrentPokemonRevision < ActiveRecord::Migration[5.1] + def up + change_table :pokeviewer_pokemon do |t| + t.references :current, null: true + end + + add_foreign_key :pokeviewer_pokemon, :pokeviewer_revisions, + column: :current_id + + Pokeviewer::Pokemon.all.each do |p| + p.current_id = p.revisions.last.id + p.save! + end + end + + def down + remove_column :pokeviewer_pokemon, :current_id + end +end -- cgit 1.4.1