kitloong / laravel-migrations-generator

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
MIT License
2.5k stars 276 forks source link

Creating indexes with length #109

Closed boryn closed 2 years ago

boryn commented 2 years ago

My table has index defined as:

INDEX `event_type_idx` (`event_type`(16)) USING BTREE

which means I want to use index of length of 16 for this field (event_type is VARCHAR(1000))

unfortunately the library produces this code: $table->index(['event_type'], 'event_type_idx');

it would be much better if it could produce: $table->index([DB::raw('event_type(16)')], 'event_type_idx');

so to take info account the real index length. Now ignoring this information may lead to failure due to MySQL index length limits (especially in multiple column indexes).

kitloong commented 2 years ago

Hi @boryn , thanks for the feature suggestion.

I will look into this issue, PR is always welcome!

kitloong commented 2 years ago

Released with tag v6.4.3