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

6vl6ewon  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(229)

我有一个表“invoice\u relations”,它是变形表。所以在迁移中我写道:
$table->morphs('invoice_relations');
但在运行迁移时会出现错误,
语法错误或访问冲突:1059标识符na
me'invoice\u relations\u invoice\u relations\u id\u invoice\u relations\u type\u index'在/var/www/html/st/sales tantra/vendor/document/dbal中过长/
lib/document/dbal/driver/pdo语句。php:105

qjp7pelc

qjp7pelc1#

改变你的想法

$table->morphs('invoice_relations');

对此:

$table->morphs('invoice_relations', 'invoice_relations_morpf_key');

或者这个:

$table->unsignedInteger("invoice_relations_id");
    $table->string("invoice_relations_type");
    $table->index(["invoice_relations_id", "invoice_relations_type"], "YOUR_INDEX_NAME");

但我认为多态关系的名称以'able'结尾,例如relationable。
https://laravel.com/docs/5.6/eloquent-relationships#polymorphic-关系

相关问题