Laravel:如何更改变形表中的默认索引键长度

Dat*_*jan 0 mysql database-migration laravel

我有表“invoice_relations”,它是变形表。所以在迁移中我写道:

$table->morphs('invoice_relations');

但是它在运行迁移时出错,

语法错误或访问冲突:1059标识符呐
我'invoice_relations_invoice_relations_id_invoice_relations_type_index'过长在/ var / www / html等/ ST /销售密宗/供应商/教义/ DBAL /
lib中/教义/ DBAL /驱动器/ PDOStatement.php:105

J. *_*Doe 7

改变你的

$table->morphs('invoice_relations');
Run Code Online (Sandbox Code Playgroud)

对此:

$table->morphs('invoice_relations', 'invoice_relations_morpf_key');
Run Code Online (Sandbox Code Playgroud)

或这个:

    $table->unsignedInteger("invoice_relations_id");
    $table->string("invoice_relations_type");
    $table->index(["invoice_relations_id", "invoice_relations_type"], "YOUR_INDEX_NAME");
Run Code Online (Sandbox Code Playgroud)

但我认为多态关系的名称以“able”结尾,例如relationable。

https://laravel.com/docs/5.6/eloquent-relationships#polymorphic-relations