2016-03-29 92 views
0

我在生產模式下遷移我的數據庫時遇到問題。導軌遷移生產數據庫不太好

migrationfile看起來是這樣的:

class ChangeCourseDefaultsNull < ActiveRecord::Migration 
def self.up 
    change_column :course_objects, :active, false, :default => 0 
end 

def self.down 
    change_column_null :course_objects, :active, true 
end 
end 

誤差

== 20150720105700 ChangeCourseDefaultsNull: migrating ========================= 
-- change_column(:course_objects, :active, false, {:default=>0}) 
rake aborted! 
StandardError: An error has occurred, all later migrations canceled: 

undefined method `to_sym' 

什麼問題呢?

回答

4

您還沒有指定的列類型booleanstring

class ChangeCourseDefaultsNull < ActiveRecord::Migration 
def self.up 
    change_column :course_objects, :active, :boolean, :default => 0 
end 

def self.down 
    change_column_null :course_objects, :active, :boolean 
end 
end