当我尝试使用Mysql2作为数据库管理器在Rails中运行以下代码时:
rake db:migrate
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
rake aborted!
"Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL:"
Run Code Online (Sandbox Code Playgroud)
如果默认情况下表中的主键不是"null",为什么会出现此错误?
但是,迁移代码:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string "first_name"
t.timestamps
end
end
end
Run Code Online (Sandbox Code Playgroud)