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

Migration failed: 1071 Specified key was too long #104

Closed
MDXDave opened this issue Aug 5, 2019 · 3 comments
Closed

Migration failed: 1071 Specified key was too long #104

MDXDave opened this issue Aug 5, 2019 · 3 comments
Labels

Comments

@MDXDave
Copy link
Contributor

MDXDave commented Aug 5, 2019

*** applying m190417_133209_init
> create table {{%User}} ... done (time: 0.291s)
> create unique index idx_User_email on {{%User}} (email) ...Exception: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
The SQL being executed was: ALTER TABLE User ADD UNIQUE INDEX idx_User_email
...
*** failed to apply m190417_133209_init (time: 0.293s)

0 from 1 migrations were applied.

Migration failed. The rest of the migrations are canceled.
Script @php yii migrate/up --interactive=0 handling the 304952f34c6bafa760b525408c8f0c941565000511 event returned with error code 1
Script presentator\api\base\Starter::postCmd handling the post-install-cmd event terminated with an exception

The fix is easy, just apply the following options to your mysql database (global, you will need root access to your database):

Set global innodb_file_format=Barracuda;
Set global innodb_large_prefix=1;
Set global innodb_default_row_format=dynamic;

@ganigeorgiev maybe you should mention this in the installation instructions 😄

@ganigeorgiev
Copy link
Member

@MDXDave Thanks, for reporting the issue, but I'm unable to reproduce it (just tested it with the default configurations for MariaDB 10.2 and MySQL 5.7).

In order to reproduce it locally, could you please post what SQL database you are using, including the version and the db collation.

@MDXDave
Copy link
Contributor Author

MDXDave commented Aug 5, 2019

I am using MariaDB version 10.1.38-MariaDB-0+deb9u1

The default collation is utf8mb4_general_ci (character set utf8mb4)

@ganigeorgiev
Copy link
Member

@MDXDave It seems that the 767 bytes limit is the default for MySql up to 5.6 and MariaDB up to 10.1. In MySQL 5.7+ and MariaDB 10.2+ this limit is increased (~3000 bytes) and the error should not occur.

I added a note in the requirements section.

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

No branches or pull requests

2 participants