Creating tables and problems with primary key in Rails
问题 When I try to run the following code in Rails using Mysql2 as database manager: rake db:migrate I obtain the following error: rake aborted! "Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL:" Why do I get this error, if the primary key in a table by default is NOT "null"? Migration code, however : class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string "first_name" t.timestamps end end end 回答1: I had a same problem before, and I solved according to