Laravel : How can I change default indexing key length in morph table

Dattaraj Mahajan

I have table "invoice_relations" which is morph table. So in migration I wrote :

$table->morphs('invoice_relations');

But it gives error while running migration as,

Syntax error or access violation: 1059 Identifier na
me 'invoice_relations_invoice_relations_id_invoice_relations_type_index' is too long in /var/www/html/st/sales-tantra/vendor/doctrine/dbal/
lib/Doctrine/DBAL/Driver/PDOStatement.php:105

J. Doe

Change your

$table->morphs('invoice_relations');

To this:

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

Or this:

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

But I think name for polymorphic relations name ends 'able', for example relationable.

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can i change the default user table in auth laravel 6

Can I change default foreign key for my Laravel Relationship?

Laravel change default primary key of users table

How can I change the default filter Windows is using for indexing file contents?

How can I change the value of a row with indexing?

How i can Change the default table name in the admin interface in django

Laravel: How can i change the default Auth Password field name

Laravel migration: How can i change the default value of a ENUM datatype?

How can I change style of default errors in Laravel 7?

How can I change the position of a morph in smalltalk? 2D Grid

How to change column length of existing table in laravel?

Can I put a morph map "alias" in a laravel eloquent model?

How can I change Laravel SQL Table Query?

How can I change the default max length of string properties in Entity Framework 6?

How can I change animation clip length?

How can I change the length of a vector in Rust?

How can i add indexing in mysql view table

How can I let a hexagon morph into a triangle (animation)

the default table name is "votes" for gem acts_as_votable, can I change to whatever name I want? and how?

Can I change User table structure in laravel?

How can I change the length of each table to be equal to the longest one provided that the longest one has a length greater than or equal to 5?

Laravel morph table with morph field id size larger than one

How can I change the default music player?

How can I change the parameters of a default constructor?

How can I change the default gateway?

How can I change the default Nautilus Bookmarks?

How can I change the default user in MySQL?

How Can i change default font of Ckeditor?

How can I change the default font for UIBarButtonItems?