Update
This commit is contained in:
@@ -28,7 +28,6 @@ public function up(): void
|
||||
$table->string('webm_url');
|
||||
$table->string('gif_url');
|
||||
$table->string('webp_url');
|
||||
$table->vector('embedding', 384)->nullable();
|
||||
$table->double('duration')->nullable();
|
||||
$table->integer('media_width')->default(720);
|
||||
$table->integer('media_height')->default(1280);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('keyword_embeddings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->text('keyword')->unique()->index();
|
||||
$table->vector('embedding', 384);
|
||||
$table->string('tag')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
// Add indexes for performance
|
||||
$table->index(['keyword']);
|
||||
$table->index(['tag']);
|
||||
});
|
||||
|
||||
// Add HNSW index for fast vector similarity search
|
||||
DB::statement('CREATE INDEX keyword_embeddings_embedding_hnsw_idx ON keyword_embeddings USING hnsw (embedding vector_cosine_ops)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('keyword_embeddings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('keyword_embeddings', function (Blueprint $table) {
|
||||
// Drop the index first, then the column
|
||||
$table->dropIndex(['tag']);
|
||||
$table->dropColumn('tag');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('keyword_embeddings', function (Blueprint $table) {
|
||||
// Add the column back
|
||||
$table->string('tag')->nullable();
|
||||
// Add the index back
|
||||
$table->index(['tag']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('meme_media_embeddings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('meme_media_id')->references('id')->on('meme_medias');
|
||||
$table->text('keyword')->index();
|
||||
$table->vector('embedding', 384);
|
||||
$table->string('tag')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('tag');
|
||||
});
|
||||
|
||||
DB::statement('CREATE INDEX meme_media_embeddings_embedding_hnsw_idx ON meme_media_embeddings USING hnsw (embedding vector_cosine_ops)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('meme_media_embeddings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement('CREATE INDEX category_embeddings_embedding_hnsw_idx ON categories USING hnsw (embedding vector_cosine_ops)');
|
||||
DB::statement('CREATE INDEX background_media_embeddings_embedding_hnsw_idx ON background_medias USING hnsw (embedding vector_cosine_ops)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement('DROP INDEX IF EXISTS category_embeddings_embedding_hnsw_idx');
|
||||
DB::statement('DROP INDEX IF EXISTS background_media_embeddings_embedding_hnsw_idx');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user