about summary refs log tree commit diff stats
path: root/db
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-10-03 15:11:00 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-10-03 15:11:00 -0400
commitb618e52428bb659cb1fe3bdbe3d3763d48b4556c (patch)
tree58446ae6883c4257013bc93375cfd668720bce95 /db
parent34830f2e96e4213e8acb10ea457244c7523aeb5a (diff)
downloadpokeviewer-b618e52428bb659cb1fe3bdbe3d3763d48b4556c.tar.gz
pokeviewer-b618e52428bb659cb1fe3bdbe3d3763d48b4556c.tar.bz2
pokeviewer-b618e52428bb659cb1fe3bdbe3d3763d48b4556c.zip
Made "met location" into an actual association
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20171003154157_rename_pokemon_met_location.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/db/migrate/20171003154157_rename_pokemon_met_location.rb b/db/migrate/20171003154157_rename_pokemon_met_location.rb new file mode 100644 index 0000000..4ccba57 --- /dev/null +++ b/db/migrate/20171003154157_rename_pokemon_met_location.rb
@@ -0,0 +1,30 @@
1class RenamePokemonMetLocation < ActiveRecord::Migration[5.1]
2 def up
3 add_column :pokeviewer_pokemon, :location_id, :integer, null: true
4
5 add_foreign_key :pokeviewer_pokemon, :pokeviewer_locations,
6 column: :location_id
7
8 Pokeviewer::Pokemon.all.each do |p|
9 unless p.met_location.nil?
10 p.location_id = p.met_location.to_i
11 p.save!
12 end
13 end
14
15 remove_column :pokeviewer_pokemon, :met_location
16 end
17
18 def down
19 add_column :pokeviewer_pokemon, :met_location, :string
20
21 Pokeviewer::Pokemon.all.each do |p|
22 unless p.location_id.nil?
23 p.met_location = p.location_id.to_s
24 p.save!
25 end
26 end
27
28 remove_column :pokeviewer_pokemon, :location_id
29 end
30end