我在生产模式下迁移数据库时遇到了问题。
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'
什么出错?
答案 0 :(得分:4)
您尚未指定列类型boolean
或string
等
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