diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-10-15 13:49:03 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-10-15 13:49:03 -0400 |
commit | 9d6d876c62408c69c654aab1a664f1294ec668b7 (patch) | |
tree | 45442d5895cc2c1dc6aac9f7a3b6abf64ded20bf /db/migrate/20171015171555_rename_pokemon_met_location.pokeviewer.rb | |
parent | 946eda79a292cb792a61a6d7ecb2ca932de65ecd (diff) | |
download | thoughts-9d6d876c62408c69c654aab1a664f1294ec668b7.tar.gz thoughts-9d6d876c62408c69c654aab1a664f1294ec668b7.tar.bz2 thoughts-9d6d876c62408c69c654aab1a664f1294ec668b7.zip |
Added pokeviewer
Diffstat (limited to 'db/migrate/20171015171555_rename_pokemon_met_location.pokeviewer.rb')
-rw-r--r-- | db/migrate/20171015171555_rename_pokemon_met_location.pokeviewer.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/db/migrate/20171015171555_rename_pokemon_met_location.pokeviewer.rb b/db/migrate/20171015171555_rename_pokemon_met_location.pokeviewer.rb new file mode 100644 index 0000000..afb5987 --- /dev/null +++ b/db/migrate/20171015171555_rename_pokemon_met_location.pokeviewer.rb | |||
@@ -0,0 +1,31 @@ | |||
1 | # This migration comes from pokeviewer (originally 20171003154157) | ||
2 | class RenamePokemonMetLocation < ActiveRecord::Migration[5.1] | ||
3 | def up | ||
4 | add_column :pokeviewer_pokemon, :location_id, :integer, null: true | ||
5 | |||
6 | add_foreign_key :pokeviewer_pokemon, :pokeviewer_locations, | ||
7 | column: :location_id | ||
8 | |||
9 | Pokeviewer::Pokemon.all.each do |p| | ||
10 | unless p.met_location.nil? | ||
11 | p.location_id = p.met_location.to_i | ||
12 | p.save! | ||
13 | end | ||
14 | end | ||
15 | |||
16 | remove_column :pokeviewer_pokemon, :met_location | ||
17 | end | ||
18 | |||
19 | def down | ||
20 | add_column :pokeviewer_pokemon, :met_location, :string | ||
21 | |||
22 | Pokeviewer::Pokemon.all.each do |p| | ||
23 | unless p.location_id.nil? | ||
24 | p.met_location = p.location_id.to_s | ||
25 | p.save! | ||
26 | end | ||
27 | end | ||
28 | |||
29 | remove_column :pokeviewer_pokemon, :location_id | ||
30 | end | ||
31 | end | ||