我全新安装了 Laravel 5.5,但是当我尝试安装 Voyager 管理面板时出现此错误:
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `translations` add unique `translati
ons_table_name_column_name_foreign_key_locale_unique`(`table_name`, `column_name`, `foreign_key`, `locale`))
配置
PHP 版本:7.0.10 MYSQL版本:5.7.14代码更新
我想我已经找到了相关的代码:
Schema::create('translations', function (Blueprint $table) {
$table->increments('id');
$table->string('table_name');
$table->string('column_name');
$table->integer('foreign_key')->unsigned();
$table->string('locale');
$table->text('value');
$table->unique(['table_name', 'column_name', 'foreign_key', 'locale']); // SOURCE OF THE ERROR ?
});
最佳答案
您需要更新“mysql”的“config/database.php”。
'engine' => null
至
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
同时更新“app/Providers/AppServiceProvider.php”
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// Specified key was too long error, Laravel News post:
Schema::defaultStringLength(191);
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
并在项目文件夹中运行这些命令。
php artisan 缓存:清除
php artisan 配置:清除
php artisan voyager:install --with-dummy
关于laravel - 安装 Laravel Voyager 包时迁移错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46363547/