Let's say I start with this model:
class Location < ActiveRecord::Base
attr_accessible :company_name, :location_name
end
Now I want to reorganize one of the values into a related model.
class CreateCompanies < ActiveRecord::Migration
def self.up
create_table :companies do |t|
t.string :name, :null => false
t.timestamps
end
add_column :locations, :company_id, :integer, :null => false
end
def self.down
drop_table :companies
remove_column :locations, :company_id
end
end
class Location < ActiveRecord::Base
attr_accessible :location_name
belongs_to :company
end
class Company < ActiveRecord::Base
has_many :locations
end
All this works great during development, as I do everything in a row; but if I try to install this in my intermediate environment, I will have problems.
The problem is that since my code has already changed to reflect the migration, it causes the environment to crash when trying to migrate.
Has anyone else dealt with this problem? Am I resigned to divide my deployment into several phases?
, ; , . . @noodl , , - . .