about summary refs log tree commit diff stats
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb20
-rw-r--r--db/schema.rb5
2 files changed, 24 insertions, 1 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)
2class 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
20end
diff --git a/db/schema.rb b/db/schema.rb index 7a7be14..f4243a4 100644 --- a/db/schema.rb +++ b/db/schema.rb
@@ -10,7 +10,7 @@
10# 10#
11# It's strongly recommended that you check this file into your version control system. 11# It's strongly recommended that you check this file into your version control system.
12 12
13ActiveRecord::Schema.define(version: 20180113211911) do 13ActiveRecord::Schema.define(version: 20180114181813) do
14 14
15 create_table "ckeditor_assets", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 15 create_table "ckeditor_assets", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
16 t.string "data_file_name", null: false 16 t.string "data_file_name", null: false
@@ -98,6 +98,8 @@ ActiveRecord::Schema.define(version: 20180113211911) do
98 t.integer "slot" 98 t.integer "slot"
99 t.integer "location_id" 99 t.integer "location_id"
100 t.string "pokeball", null: false 100 t.string "pokeball", null: false
101 t.bigint "current_id"
102 t.index ["current_id"], name: "index_pokeviewer_pokemon_on_current_id"
101 t.index ["key"], name: "index_pokeviewer_pokemon_on_key", unique: true 103 t.index ["key"], name: "index_pokeviewer_pokemon_on_key", unique: true
102 t.index ["trainer_id"], name: "index_pokeviewer_pokemon_on_trainer_id" 104 t.index ["trainer_id"], name: "index_pokeviewer_pokemon_on_trainer_id"
103 t.index ["uuid"], name: "index_pokeviewer_pokemon_on_uuid", unique: true 105 t.index ["uuid"], name: "index_pokeviewer_pokemon_on_uuid", unique: true
@@ -237,5 +239,6 @@ ActiveRecord::Schema.define(version: 20180113211911) do
237 t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true 239 t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
238 end 240 end
239 241
242 add_foreign_key "pokeviewer_pokemon", "pokeviewer_revisions", column: "current_id"
240 add_foreign_key "pokeviewer_revisions", "pokeviewer_species", column: "species_id" 243 add_foreign_key "pokeviewer_revisions", "pokeviewer_species", column: "species_id"
241end 244end