I am having a problem with laravel migration where I need to set the index length for a specific column, but it looks like Schema / Blueprint index () does not have such a function. Laravel docs
[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'description' used in key specification without a key length (SQL: alter table `Customers` add index `description_idx`(`description`))
Original sql query line:
KEY `description_idx` (`description`(100)) // index length = 100
Laravel migration code line:
$table->text('description')->nullable()->index('`description_idx`'); // no index length here
The moment I feel that the best thing I can do is change the type of the column, but maybe there is a more suitable way to fix this problem?
source share