0
votes

I hope my question makes sense as I'm a bit confused on what I should be doing.

I have cloned a laravel project and there are about 20 migrations already there in the folder. From my understanding, migrations are the tables?

I have created an empty mysql database that links to this laravel project which currently has a migrations table and a users table.

I think I am supposed to do something to generate the tables written in the migrations folder on the new database but I'm not sure how.

So far I have used the command php artisan migrate which generates a migrations and users table and comes up with these errors.

[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t oo long; max key length is 1000 bytes (SQL: alter table users add unique
users_email_unique(email))


[Doctrine\DBAL\Driver\PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t oo long; max key length is 1000 bytes


[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t oo long; max key length is 1000 bytes

1
which version of laravel u are using?Romantic Dev
"max key length is 1000 bytes" - Are you using MyISAM?Paul Spiegel

1 Answers

3
votes

Laravel 5.4 made a change to the default database character set, and it’s now utf8mb4 which includes support for storing emojis. This only affects new applications and as long as you are running MySQL v5.7.7 and higher you do not need to do anything.

For those running MariaDB or older versions of MySQL you may hit this error when trying to run migrations:

[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email))

[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

As outlined in the Migrations guide to fix this all you have to do is edit your AppServiceProvider.php file and inside the boot method set a default string length:

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}