Created
May 30, 2017 13:09
-
-
Save mindmergedesign/74a9261a700be2ca53a59e30f83dcf6e to your computer and use it in GitHub Desktop.
Laravel 5.4: Specified key was too long error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // AppServiceProvider.php | |
| use Illuminate\Support\Facades\Schema; | |
| public function boot() | |
| { | |
| Schema::defaultStringLength(191); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
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: