mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Concerns\Elastic\ConfiguresTextAnalyzers;
|
|
use Elastic\Adapter\Indices\Mapping;
|
|
use Elastic\Adapter\Indices\Settings;
|
|
use Elastic\Migrations\Facades\Index;
|
|
use Elastic\Migrations\MigrationInterface;
|
|
|
|
final class CreateStudioIndex implements MigrationInterface
|
|
{
|
|
use ConfiguresTextAnalyzers;
|
|
|
|
/**
|
|
* Run the migration.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Index::createIfNotExists('studios', function (Mapping $mapping, Settings $settings) {
|
|
$this->configureTextAnalyzers($settings);
|
|
|
|
$mapping->date('created_at');
|
|
$mapping->text('name', [
|
|
'analyzer' => 'name_search',
|
|
'fields' => [
|
|
'keyword' => [
|
|
'type' => 'keyword',
|
|
],
|
|
],
|
|
]);
|
|
$mapping->text('slug', [
|
|
'fields' => [
|
|
'keyword' => [
|
|
'type' => 'keyword',
|
|
],
|
|
],
|
|
]);
|
|
$mapping->long('studio_id');
|
|
$mapping->date('updated_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migration.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Index::dropIfExists('studios');
|
|
}
|
|
}
|