rails migration production db工作不正常

时间:2016-03-29 10:17:45

标签: ruby-on-rails ruby ruby-on-rails-4

我在生产模式下迁移数据库时遇到了问题。

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'

什么出错?

1 个答案:

答案 0 :(得分: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