From 62ffd6ca978159889a87dfe4321c1c790f9108b6 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 14 Jan 2018 13:18:29 -0500 Subject: Added migration from previous pokeviewer update --- ...1813_cache_current_pokemon_revision.pokeviewer.rb | 20 ++++++++++++++++++++ db/schema.rb | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20180114181813_cache_current_pokemon_revision.pokeviewer.rb (limited to 'db') 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 @@ +# This migration comes from pokeviewer (originally 20180114170238) +class CacheCurrentPokemonRevision < ActiveRecord::Migration[5.1] + def up + change_table :pokeviewer_pokemon do |t| + t.references :current, null: true + end + + add_foreign_key :pokeviewer_pokemon, :pokeviewer_revisions, + column: :current_id + + Pokeviewer::Pokemon.all.each do |p| + p.current_id = p.revisions.last.id + p.save! + end + end + + def down + remove_column :pokeviewer_pokemon, :current_id + end +end 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 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180113211911) do +ActiveRecord::Schema.define(version: 20180114181813) do create_table "ckeditor_assets", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| t.string "data_file_name", null: false @@ -98,6 +98,8 @@ ActiveRecord::Schema.define(version: 20180113211911) do t.integer "slot" t.integer "location_id" t.string "pokeball", null: false + t.bigint "current_id" + t.index ["current_id"], name: "index_pokeviewer_pokemon_on_current_id" t.index ["key"], name: "index_pokeviewer_pokemon_on_key", unique: true t.index ["trainer_id"], name: "index_pokeviewer_pokemon_on_trainer_id" t.index ["uuid"], name: "index_pokeviewer_pokemon_on_uuid", unique: true @@ -237,5 +239,6 @@ ActiveRecord::Schema.define(version: 20180113211911) do t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end + add_foreign_key "pokeviewer_pokemon", "pokeviewer_revisions", column: "current_id" add_foreign_key "pokeviewer_revisions", "pokeviewer_species", column: "species_id" end -- cgit 1.4.1