Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users table is not compatible with MySQL 5.7 #212

Open
rporres opened this issue Jul 23, 2018 · 0 comments
Open

Users table is not compatible with MySQL 5.7 #212

rporres opened this issue Jul 23, 2018 · 0 comments
Labels

Comments

@rporres
Copy link
Collaborator

rporres commented Jul 23, 2018

When trying to initialise the database we get (formatted)

Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead: 
CREATE TABLE `users` (
`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, 
`username` varchar(255) DEFAULT '' NOT NULL, 
`email` varchar(255) DEFAULT '' NOT NULL,
 `encrypted_password` varchar(255) DEFAULT '' NOT NULL, 
`reset_password_token` varchar(255),
`reset_password_sent_at` datetime,
 `remember_created_at` datetime,
 `sign_in_count` int(11) DEFAULT 0,
 `current_sign_in_at` datetime,
 `last_sign_in_at` datetime,
 `current_sign_in_ip` varchar(255), 
`last_sign_in_ip` varchar(255),
 `created_at` datetime NOT NULL, 
`updated_at` datetime NOT NULL) ENGINE=InnoDB
/usr/lib/ruby/gems/1.9.1/gems/mysql2-0.3.21/lib/mysql2/client.rb:85:in `_query'
/usr/lib/ruby/gems/1.9.1/gems/mysql2-0.3.21/lib/mysql2/client.rb:85:in `query'

The problem is 5.7 no longer supporting null values for the primary key.

https://dev.mysql.com/doc/refman/5.7/en/create-table.html#create-table-indexes-keys

A unique index where all key columns must be defined as NOT NULL. If they are not explicitly declared as NOT NULL, MySQL declares them so implicitly (and silently). A table can have only one PRIMARY KEY.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants