Moving bike model to the bikes table

Leaving the bike_models table and bikes.bike_model_id column as a backup.
This commit is contained in:
Jason Denney
2013-09-02 17:26:07 -04:00
parent 3c4e5c21c2
commit 47f616b7b0
6 changed files with 17 additions and 13 deletions
@@ -0,0 +1,10 @@
class AddModelToBike < ActiveRecord::Migration
def change
add_column :bikes, :model, :string
change_column :bikes, :bike_model_id, :integer, :null => true
Bike.all.each do |bike|
bike.model = BikeModel.find_by_id(bike.bike_model_id).model
bike.save
end
end
end
+3 -2
View File
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130902164600) do
ActiveRecord::Schema.define(:version => 20130902201853) do
create_table "bike_actions", :force => true do |t|
t.string "action", :limit => 128, :null => false
@@ -49,7 +49,7 @@ ActiveRecord::Schema.define(:version => 20130902164600) do
create_table "bikes", :force => true do |t|
t.string "serial_number"
t.integer "bike_brand_id", :null => false
t.integer "bike_model_id", :null => false
t.integer "bike_model_id"
t.string "color"
t.integer "bike_style_id", :null => false
t.float "seat_tube_height"
@@ -61,6 +61,7 @@ ActiveRecord::Schema.define(:version => 20130902164600) do
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "shop_id"
t.string "model"
end
add_index "bikes", ["shop_id"], :name => "index_bikes_on_shop_id", :unique => true