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

Can't migrate at install time #66

Open
jlecour opened this issue Aug 6, 2018 · 1 comment
Open

Can't migrate at install time #66

jlecour opened this issue Aug 6, 2018 · 1 comment

Comments

@jlecour
Copy link
Member

jlecour commented Aug 6, 2018

== 20180523145630 DeviseCreateUsers: migrating ================================
-- create_table(:users)
   -> 0.0241s
-- add_index(:users, :email, {:unique=>true})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Specified key was too long; max key length is 767 bytes: CREATE UNIQUE INDEX `index_users_on_email`  ON `users` (`email`) 
/localhome/jlecour/work/intra/chexpire/db/migrate/20180523145630_devise_create_users.rb:41:in `change'
/home/jlecour/.rbenv/versions/2.5.1/bin/bundle:23:in `load'
/home/jlecour/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'

Caused by:
ActiveRecord::StatementInvalid: Mysql2::Error: Specified key was too long; max key length is 767 bytes: CREATE UNIQUE INDEX `index_users_on_email`  ON `users` (`email`) 
/localhome/jlecour/work/intra/chexpire/db/migrate/20180523145630_devise_create_users.rb:41:in `change'
/home/jlecour/.rbenv/versions/2.5.1/bin/bundle:23:in `load'
/home/jlecour/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'

Caused by:
Mysql2::Error: Specified key was too long; max key length is 767 bytes
/localhome/jlecour/work/intra/chexpire/db/migrate/20180523145630_devise_create_users.rb:41:in `change'
/home/jlecour/.rbenv/versions/2.5.1/bin/bundle:23:in `load'
/home/jlecour/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
@jlecour
Copy link
Member Author

jlecour commented Aug 6, 2018

There is a complex issue which depends on the verison of MySQL/MariaDB.

Basically, if you use MySQL < 5.7 (MySQL 5.5 or MariaDB 10.1) the workaround is to force the server to create tables with "utf8" instead of "utf8mb4" :

character-set-server=utf8
collation-server=utf8_general_ci

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

No branches or pull requests

1 participant