about summary refs log tree commit diff stats
path: root/db/migrate
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-01-13 16:19:36 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-01-13 16:19:36 -0500
commit0bfb8ae3ec6348664c4625df89b252193aa14725 (patch)
tree36b7c44541f1bd933cbdc95e112ab69bc22b49d4 /db/migrate
parent0b0f8509452c7206e52e8ce2c47a8f54d88f652c (diff)
downloadthoughts-0bfb8ae3ec6348664c4625df89b252193aa14725.tar.gz
thoughts-0bfb8ae3ec6348664c4625df89b252193aa14725.tar.bz2
thoughts-0bfb8ae3ec6348664c4625df89b252193aa14725.zip
Actually added migration from previous commit
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20180113211911_move_species_to_revision.pokeviewer.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/db/migrate/20180113211911_move_species_to_revision.pokeviewer.rb b/db/migrate/20180113211911_move_species_to_revision.pokeviewer.rb new file mode 100644 index 0000000..bd19f21 --- /dev/null +++ b/db/migrate/20180113211911_move_species_to_revision.pokeviewer.rb
@@ -0,0 +1,40 @@
1# This migration comes from pokeviewer (originally 20180113200119)
2class MoveSpeciesToRevision < ActiveRecord::Migration[5.1]
3 def up
4 change_table :pokeviewer_revisions do |t|
5 t.references :species, null: true
6 end
7
8 Pokeviewer::Revision.all.each do |r|
9 r.species_id = r.pokemon.species_id
10 r.save!
11 end
12
13 remove_column :pokeviewer_pokemon, :species_id
14
15 change_column_null :pokeviewer_revisions, :species_id, false
16
17 add_foreign_key :pokeviewer_revisions, :pokeviewer_species,
18 column: :species_id
19 end
20
21 def down
22 def up
23 change_table :pokeviewer_pokemon do |t|
24 t.references :species, null: true
25 end
26
27 Pokeviewer::Pokemon.all.each do |p|
28 p.species_id = p.revisions.first.species_id
29 p.save!
30 end
31
32 remove_column :pokeviewer_revisions, :species_id
33
34 change_column_null :pokeviewer_pokemon, :species_id, false
35
36 add_foreign_key :pokeviewer_pokemon, :pokeviewer_species,
37 column: :species_id
38 end
39 end
40end