n How to configure the default string length generated by migrations in Laravel 7 | CodimTh

Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh
Category:

in this tuto, I will show you how to manually configure the default string length generated by migrations in order for MySQL to create indexes for them.

You may configure this by calling the Schema::defaultStringLength method within your AppServiceProvider:

Example

<?php


namespace App\Providers;


use Illuminate\Database\Schema\Builder;

use Illuminate\Support\ServiceProvider;


class AppServiceProvider extends ServiceProvider

{

    /**

     * Register any application services.

     *

     * @return void

     */

    public function register()

    {

        //

    }


    /**

     * Bootstrap any application services.

     *

     * @return void

     */

    public function boot()

    {

        Builder::defaultStringLength(191);

    }

}

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts

Search

Page Facebook