Schema Default Schema Length

Schema Default Schema Length
Laravel migration: unique key is too long, even if specified [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_uniq(email))

Error handling Code

Schema::defaultStringLength(191);

Where file using

go file app/provider/AppServiceProvider.php


class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Schema::defaultStringLength(191);
    }
}

Write a Associte Comment
Markdown Editor