Laravel migration error: Specified key was too long

Written by | Posted on March 24th, 2018
Laravel migration error: Specified key was too long

This tutorial is about on how to fix the laravel migration error: Specified key was too long without further due let’s dive in.

If you are upgrading your Laravel PHP framework version to the new one from Laravel 5.5 to Laravel 5.6 you face the same issue migration error.

This error is very annoying when every time you do the PHP artisan migration it appears the long error code in your terminal command prompts.

It will cost you a lot of time and effort to google it and seeking some help on how to resolve this kind of problem but I have a simple solution for this.

First, go back to your phpMyAdmin and click your database name and navigate the two table name migrations and users to drop as shown in the picture.

Migrations and Users Table

And then go to your favorite IDE and find or navigate the folder name database->migration folder

Migration Folder

Inside migration folder, you can see two PHP files, one is for users table and password reset table.

You need to edit and add this code line to your PHP files at the top of your schema create a function

It will look like this

The same in your password reset PHP file you need to put this code also

Then go back to your terminal command prompt and run the php artisan migrate

As you can see all your created users and password reset PHP table successfully migrated to your phpMyAdmin database.

Migration Successfully

The sole purpose I created this article is to fundamentally fulfill the error of my previous article on Laravel Login Log Out using Authentication.

I hope this Laravel Migration Error article can help you if you like this tutorial, please like and share it to your Social Media spread it like a virus so you can help the other people’s.

Happy Coding 🙂