1. 手动配置迁移命令migrate生成的默认字符串长度,在AppServiceProvider中调用Schema::defaultStringLength方法来实现配置:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    
        /**
         * Bootstrap any application services.
         *
         * @return void
         */
        public function boot()
        {
            //
            Schema::defaultStringLength(191);
        }