尝试将 NOT NULL 列添加到现有表时出现以下错误。为什么会这样?。我尝试 rake db:reset 认为现有记录是问题,但即使在重置数据库后,问题仍然存在。你能帮我解决这个问题吗?
迁移文件
class AddDivisionIdToProfile < ActiveRecord::Migration
def self.up
add_column :profiles, :division_id, :integer, :null => false
end
def self.down
remove_column :profiles, :division_id
end
end
错误信息
SQLite3::SQLException:无法添加默认值为 NULL 的 NOT NULL 列:ALTER TABLE "profiles" ADD "division_id" integer NOT NULL