PRIMARY KEY issue with creating tables in Rails using rake db:migrate command with mysql

后端 未结 5 1251
余生分开走
余生分开走 2020-12-31 00:38

My version of rails is 4.0.0, my version of mysql is Ver 14.14 Distrib 5.7.9, for Win64 (x86_64). I am operating of an older version of rails as I was getting some clashes w

5条回答
  •  孤独总比滥情好
    2020-12-31 01:03

    Since MySQL 5.7.3 a primary key declared as NULL produces an error:

    Columns in a PRIMARY KEY must be NOT NULL, but if declared explicitly as NULL produced no error. Now an error occurs. For example, a statement such as CREATE TABLE t (i INT NULL PRIMARY KEY) is rejected. The same occurs for similar ALTER TABLE statements. (Bug #13995622, Bug #66987, Bug #15967545, Bug #16545198)

    But the create_table in your Rails version still wants a DEFAULT or NULL for the PRIMARY KEY. I have solved the issue by updating to a newer rails version.

提交回复
热议问题