27 lines
838 B
PHP
27 lines
838 B
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration {
|
|
public function up(): void
|
|
{
|
|
Schema::create('articles', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('title');
|
|
$table->text('content');
|
|
$table->timestamps();
|
|
});
|
|
|
|
$dimension = (int) config('services.embedding.dimension', 768);
|
|
DB::statement("ALTER TABLE articles ADD COLUMN embedding vector({$dimension})");
|
|
DB::statement('CREATE INDEX articles_embedding_cosine_idx ON articles USING ivfflat (embedding vector_cosine_ops)');
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('articles');
|
|
}
|
|
}; |