about summary refs log tree commit diff stats
path: root/db/migrate/20171015171555_rename_pokemon_met_location.pokeviewer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20171015171555_rename_pokemon_met_location.pokeviewer.rb')
-rw-r--r--db/migrate/20171015171555_rename_pokemon_met_location.pokeviewer.rb31
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)
2class 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
31end