我正在尝试在laravel5.8 thru命令
中迁移mysql表$ php artisan migrate
我遇到此错误
In Facade.php line 237:
Call to undefined method
IlluminateDatabaseSchemaMySqlBuilder::defaultStringLenght()
我已经在appserviceprovider.php文件中设置 use IlluminateSupportFacadesSchema;
defaultStringLenght(191); // boot() method
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->mediumText('body');
$table->timestamps();
});
首先,您需要正确调用该方法并检查拼写长度。
public function boot()
{
Schema::defaultStringLength(191);
}
您还需要导入模式外观
use IlluminateSupportFacadesSchema;
在app providers appserviceprovider.php中您需要使用
use IlluminateSupportFacadesSchema;
然后在启动功能中您需要写架构:: DefaultStringLength(191(;而且您的启动功能看起来像这样
public function boot()
{
Schema::defaultStringLength(191);
}