FULLTEXT Indexes at migrations
How can I create an Fulltext Index for a column in my migration file?
Didn't found anything about this in Laravel Docs...
That ?
$table->text('description')->unique();
Will it work for
$table->string('column', 1024)->unique();
?
This will not work, because the max is 767
$table->string('column', 1024)->unique();
Exactly. For fields with length greater then 767 characters, I need to use "FULLTEXT" index. It's different from "UNIQUE" index.
Is there any way to create fulltext indexes in Laravel Schema Builder? Or I will need to create it with a SQL query?
The Taylor answer for why this is not in Laravel. So you need a raw command.
You have to use SQL statements, but you can put them in your migration:
DB::statement('ALTER TABLE posts ADD FULLTEXT full(name, content)');
This doesn't work if you have table prefixes, I had to write
DB::statement('ALTER TABLE '.DB::getTablePrefix().'laravel_fulltext ADD FULLTEXT fulltext_title(indexed_title)');
to get the right table prefix.
Is there a better way?
Please or to participate in this conversation.