|
4 | 4 |
|
5 | 5 | use Illuminate\Database\Schema\Blueprint;
|
6 | 6 | use Illuminate\Support\Fluent;
|
| 7 | +use RuntimeException; |
7 | 8 |
|
8 | 9 | class PostgresGrammar extends Grammar
|
9 | 10 | {
|
@@ -176,6 +177,31 @@ public function compileIndex(Blueprint $blueprint, Fluent $command)
|
176 | 177 | );
|
177 | 178 | }
|
178 | 179 |
|
| 180 | + /** |
| 181 | + * Compile a fulltext index key command. |
| 182 | + * |
| 183 | + * @param \Illuminate\Database\Schema\Blueprint $blueprint |
| 184 | + * @param \Illuminate\Support\Fluent $command |
| 185 | + * @return string |
| 186 | + * |
| 187 | + * @throws \RuntimeException |
| 188 | + */ |
| 189 | + public function compileFulltext(Blueprint $blueprint, Fluent $command) |
| 190 | + { |
| 191 | + $language = $command->language ?: 'english'; |
| 192 | + |
| 193 | + if (count($command->columns) > 1) { |
| 194 | + throw new RuntimeException('The PostgreSQL driver does not support fulltext index creation using multiple columns.'); |
| 195 | + } |
| 196 | + |
| 197 | + return sprintf('create index %s on %s using gin (to_tsvector(%s, %s))', |
| 198 | + $this->wrap($command->index), |
| 199 | + $this->wrapTable($blueprint), |
| 200 | + $this->quoteString($language), |
| 201 | + $this->wrap($command->columns[0]) |
| 202 | + ); |
| 203 | + } |
| 204 | + |
179 | 205 | /**
|
180 | 206 | * Compile a spatial index key command.
|
181 | 207 | *
|
@@ -359,6 +385,18 @@ public function compileDropIndex(Blueprint $blueprint, Fluent $command)
|
359 | 385 | return "drop index {$this->wrap($command->index)}";
|
360 | 386 | }
|
361 | 387 |
|
| 388 | + /** |
| 389 | + * Compile a drop fulltext index command. |
| 390 | + * |
| 391 | + * @param \Illuminate\Database\Schema\Blueprint $blueprint |
| 392 | + * @param \Illuminate\Support\Fluent $command |
| 393 | + * @return string |
| 394 | + */ |
| 395 | + public function compileDropFulltext(Blueprint $blueprint, Fluent $command) |
| 396 | + { |
| 397 | + return $this->compileDropIndex($blueprint, $command); |
| 398 | + } |
| 399 | + |
362 | 400 | /**
|
363 | 401 | * Compile a drop spatial index command.
|
364 | 402 | *
|
|
0 commit comments