From 56f5841d4b9c12296cdfcaeff174b2627d59afc8 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 7 Dec 2024 11:49:49 -0500 Subject: Migrate to full rails app --- db/migrate/20171003191205_remove_boxes.rb | 68 +++++++++++++++---------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'db/migrate/20171003191205_remove_boxes.rb') diff --git a/db/migrate/20171003191205_remove_boxes.rb b/db/migrate/20171003191205_remove_boxes.rb index 476b98a..f7258fd 100644 --- a/db/migrate/20171003191205_remove_boxes.rb +++ b/db/migrate/20171003191205_remove_boxes.rb @@ -1,6 +1,6 @@ class RemoveBoxes < ActiveRecord::Migration[5.1] def up - change_table :pokeviewer_trainers do |t| + change_table :trainers do |t| t.string :box_1_name, null: false, default: "" t.string :box_2_name, null: false, default: "" t.string :box_3_name, null: false, default: "" @@ -17,24 +17,24 @@ class RemoveBoxes < ActiveRecord::Migration[5.1] t.string :box_14_name, null: false, default: "" end - change_column_default :pokeviewer_trainers, :box_1_name, nil - change_column_default :pokeviewer_trainers, :box_2_name, nil - change_column_default :pokeviewer_trainers, :box_3_name, nil - change_column_default :pokeviewer_trainers, :box_4_name, nil - change_column_default :pokeviewer_trainers, :box_5_name, nil - change_column_default :pokeviewer_trainers, :box_6_name, nil - change_column_default :pokeviewer_trainers, :box_7_name, nil - change_column_default :pokeviewer_trainers, :box_8_name, nil - change_column_default :pokeviewer_trainers, :box_9_name, nil - change_column_default :pokeviewer_trainers, :box_10_name, nil - change_column_default :pokeviewer_trainers, :box_11_name, nil - change_column_default :pokeviewer_trainers, :box_12_name, nil - change_column_default :pokeviewer_trainers, :box_13_name, nil - change_column_default :pokeviewer_trainers, :box_14_name, nil + change_column_default :trainers, :box_1_name, nil + change_column_default :trainers, :box_2_name, nil + change_column_default :trainers, :box_3_name, nil + change_column_default :trainers, :box_4_name, nil + change_column_default :trainers, :box_5_name, nil + change_column_default :trainers, :box_6_name, nil + change_column_default :trainers, :box_7_name, nil + change_column_default :trainers, :box_8_name, nil + change_column_default :trainers, :box_9_name, nil + change_column_default :trainers, :box_10_name, nil + change_column_default :trainers, :box_11_name, nil + change_column_default :trainers, :box_12_name, nil + change_column_default :trainers, :box_13_name, nil + change_column_default :trainers, :box_14_name, nil Pokeviewer::Trainer.all.each do |t| boxes = ActiveRecord::Base.connection.select_all( - "SELECT * FROM pokeviewer_boxes WHERE trainer_id = ? ORDER BY number ASC", + "SELECT * FROM boxes WHERE trainer_id = ? ORDER BY number ASC", t.trainer_id).map { |b| b["name"] } t.box_1_name = boxes.shift @@ -55,11 +55,11 @@ class RemoveBoxes < ActiveRecord::Migration[5.1] t.save end - drop_table :pokeviewer_boxes + drop_table :boxes end def down - create_table :pokeviewer_boxes do |t| + create_table :boxes do |t| t.integer "trainer_id", null: false t.integer "number", null: false t.string "name", null: false @@ -67,9 +67,9 @@ class RemoveBoxes < ActiveRecord::Migration[5.1] t.timestamps end - add_index :pokeviewer_boxes, [:trainer_id, :number], unique: true + add_index :boxes, [:trainer_id, :number], unique: true - add_foreign_key :pokeviewer_boxes, :pokeviewer_trainers, column: :trainer_id + add_foreign_key :boxes, :trainers, column: :trainer_id Pokeviewer::Trainer.all.each do |t| Pokeviewer::Box.create(trainer_id: t.trainer_id, number: 1, name: t.box_1_name) @@ -88,19 +88,19 @@ class RemoveBoxes < ActiveRecord::Migration[5.1] Pokeviewer::Box.create(trainer_id: t.trainer_id, number: 14, name: t.box_14_name) end - remove_column :pokeviewer_trainers, :box_1_name - remove_column :pokeviewer_trainers, :box_2_name - remove_column :pokeviewer_trainers, :box_3_name - remove_column :pokeviewer_trainers, :box_4_name - remove_column :pokeviewer_trainers, :box_5_name - remove_column :pokeviewer_trainers, :box_6_name - remove_column :pokeviewer_trainers, :box_7_name - remove_column :pokeviewer_trainers, :box_8_name - remove_column :pokeviewer_trainers, :box_9_name - remove_column :pokeviewer_trainers, :box_10_name - remove_column :pokeviewer_trainers, :box_11_name - remove_column :pokeviewer_trainers, :box_12_name - remove_column :pokeviewer_trainers, :box_13_name - remove_column :pokeviewer_trainers, :box_14_name + remove_column :trainers, :box_1_name + remove_column :trainers, :box_2_name + remove_column :trainers, :box_3_name + remove_column :trainers, :box_4_name + remove_column :trainers, :box_5_name + remove_column :trainers, :box_6_name + remove_column :trainers, :box_7_name + remove_column :trainers, :box_8_name + remove_column :trainers, :box_9_name + remove_column :trainers, :box_10_name + remove_column :trainers, :box_11_name + remove_column :trainers, :box_12_name + remove_column :trainers, :box_13_name + remove_column :trainers, :box_14_name end end -- cgit 1.4.1