我有全新安装的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 ?
});
答案 0 :(得分:3)
您需要更新" config / database.php"对于' mysql'。
'发动机' =>空
要
'发动机' => ' InnoDB ROW_FORMAT = DYNAMIC',
同时更新" app / Providers / AppServiceProvider.php"
from rtfd import helpers
#helpers.formatstr is the function you're looking for
并在项目文件夹中运行这些命令。
php artisan cache:clear
php artisan config:clear
php artisan voyager:install --with-dummy
答案 1 :(得分:0)
索引的总长度太长。
添加唯一索引的列不应该像VARCHAR列那样长,因为索引会非常庞大且效率低下。
答案 2 :(得分:0)
这是一个众所周知的issue。
如果您不使用Voyager的多语言功能,只需取消注释*******************_create_translations_table
中的行
// $table->unique(['table_name', 'column_name', 'foreign_key', 'locale']);
或尝试将MySql数据库更新为7.x