Ruby on Rails migration on empty DB with renaming/adding/removing columns in the middle
by
ep
on Thu 29 Mar 2007 11:32 PM EDT |
Permanent Link
|
Cosmos
if you do
rename_column/add/remove in your migration, don't forget to call
reset_column_information in the changed class. Otherwise you may have a problem with running migration on an empty DB if you pre-seed data in the migration after change
Example:
class RenameLinkTemplateElementsToSubtemplates < ActiveRecord::Migration
def self.up
rename_column :template_elements, :template_id, :sub_template_id
TemplateElement.reset_column_information()
end
def self.down
rename_column :template_elements, :sub_template_id, :template_id
TemplateElement.reset_column_information()
end
end