Use change_table and its sub methods rather than remove_column and add_column
1 #example 2 class AddCategoryIdToPosts < ActiveRecord::Migration 3 def self.up 4 change_table :posts do |t| 5 t.references :category 6 end 7 end 8 9 def self.down 10 change_table :posts do |t| 11 t.remove_references :category 12 end 13 end 14 end
1 # another exmample. note remove_integer doesn't work. just use plain old 'remove' 2 class AddRedirectLocaleToPages < ActiveRecord::Migration 3 def self.up 4 change_table :pages do |t| 5 t.integer :redirect_locale, :default => 0 6 end 7 end 8 9 def self.down 10 change_table :pages do |t| 11 t.remove :redirect_locale, :default => 0 12 end 13 end 14 end
Spitfire Sky | github | archives | resume