about summary refs log tree commit diff stats
path: root/db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb')
-rw-r--r--db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb20
1 files changed, 20 insertions, 0 deletions
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 @@
1# This migration comes from pokeviewer (originally 20180114170238)
2class CacheCurrentPokemonRevision < ActiveRecord::Migration[5.1]
3 def up
4 change_table :pokeviewer_pokemon do |t|
5 t.references :current, null: true
6 end
7
8 add_foreign_key :pokeviewer_pokemon, :pokeviewer_revisions,
9 column: :current_id
10
11 Pokeviewer::Pokemon.all.each do |p|
12 p.current_id = p.revisions.last.id
13 p.save!
14 end
15 end
16
17 def down
18 remove_column :pokeviewer_pokemon, :current_id
19 end
20end