Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead

前端 未结 4 1758
我寻月下人不归
我寻月下人不归 2021-02-01 09:38

I have created a demo application in rails 3.2.9 and ruby versiion 2.0.0 . After scaffolding Blog model I am trying to migrate it, but having following

4条回答
  •  梦谈多话
    2021-02-01 09:54

    config/initializers/abstract_mysql2_adapter.rb

    require 'active_record/connection_adapters/mysql2_adapter'
    
    class ActiveRecord::ConnectionAdapters::Mysql2Adapter
      NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
    end
    

提交回复
热议问题