Update search and indexing

This commit is contained in:
DariusIII
2026-05-13 08:51:11 +02:00
parent 5e74a4d769
commit 282070a2af
10 changed files with 903 additions and 86 deletions
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
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
{
if ($this->indexExists('ix_releases_searchname')) {
return;
}
Schema::table('releases', function (Blueprint $table): void {
$table->index('searchname', 'ix_releases_searchname');
});
}
public function down(): void
{
if (! $this->indexExists('ix_releases_searchname')) {
return;
}
Schema::table('releases', function (Blueprint $table): void {
$table->dropIndex('ix_releases_searchname');
});
}
private function indexExists(string $keyName): bool
{
$rows = DB::select('SHOW INDEX FROM `releases` WHERE Key_name = ?', [$keyName]);
return $rows !== [];
}
};