This package revert database default string length to 255 characters in a Laravel project. It transforms all VARCHAR(191) columns to 255 characters.
This is especially useful for old projects that need to be updated.
Indeed, since Laravel 5.4 the default charset is "utf8mb4"; charset supported by MySQL from version 5.7.7 So, if the application was not running with this version at least, you had to put in the AppServiceProvider:
Schema::defaultStringLength(191);
As a result, this package will be of great help to you to modernize an old application.
Install the package with Composer:
composer require axn/laravel-revert-db-default-string-length
First create a dump of your database in case there is a problem.
If you want to run the command directly:
php artisan revert-db-default-string-length:transform
Pusblish the migration:
php artisan vendor:publish --tag="revert-db-default-string-length-migration"
So you can incorporate it into your deployment workflow with:
php artisan migrate
Remember to remove Schema::defaultStringLength(191);
from your AppServiceProvider file.