[Error] Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL when migrate

For Rails 3 + mysql 5.7:

Create new file in:

config/initializers/abstract_mysql_adapter.rb

And add content:

ActiveSupport.on_load(:active_record) do
  class ActiveRecord::ConnectionAdapters::Mysql2Adapter
    NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
  end
end
Advertisements