]> BookStack Code Mirror - bookstack/blob - database/migrations/2025_03_24_155748_create_search_vectors_table.php
d7fb0118a2fc6b2476fdd2670b73fe7a4d13d2d3
[bookstack] / database / migrations / 2025_03_24_155748_create_search_vectors_table.php
1 <?php
2
3 use Illuminate\Database\Migrations\Migration;
4 use Illuminate\Database\Schema\Blueprint;
5 use Illuminate\Support\Facades\Schema;
6
7 return new class extends Migration
8 {
9     /**
10      * Run the migrations.
11      */
12     public function up(): void
13     {
14         // TODO - Handle compatibility with older databases that don't support vectors
15         Schema::create('search_vectors', function (Blueprint $table) {
16             $table->string('entity_type', 100);
17             $table->integer('entity_id');
18             $table->text('text');
19             $table->vector('embedding');
20
21             $table->index(['entity_type', 'entity_id']);
22         });
23     }
24
25     /**
26      * Reverse the migrations.
27      */
28     public function down(): void
29     {
30         Schema::dropIfExists('search_vectors');
31     }
32 };