diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-01-14 13:18:29 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-01-14 13:18:29 -0500 |
commit | 62ffd6ca978159889a87dfe4321c1c790f9108b6 (patch) | |
tree | cfd7260cb3186ff1759761e5afcb27cee213e0ef /db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb | |
parent | 3cfdb5a1d6cff5c869f91714de02c56d8b6e211e (diff) | |
download | thoughts-62ffd6ca978159889a87dfe4321c1c790f9108b6.tar.gz thoughts-62ffd6ca978159889a87dfe4321c1c790f9108b6.tar.bz2 thoughts-62ffd6ca978159889a87dfe4321c1c790f9108b6.zip |
Added migration from previous pokeviewer update
Diffstat (limited to 'db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb')
-rw-r--r-- | db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb | 20 |
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) | ||
2 | class 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 | ||
20 | end | ||