directorytree/opensearch-migrations 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

directorytree/opensearch-migrations

Composer 安装命令:

composer require directorytree/opensearch-migrations

包简介

OpenSearch migrations for Laravel

README 文档

README

OpenSearch index migrations for Laravel.

Installation

Install the package with Composer:

composer require directorytree/opensearch-migrations

Publish the OpenSearch client configuration:

php artisan vendor:publish --provider="DirectoryTree\OpenSearchClient\OpenSearchClientServiceProvider"

Publish the migration configuration:

php artisan vendor:publish --provider="DirectoryTree\OpenSearchMigrations\OpenSearchMigrationsServiceProvider"

Configuration

The migration configuration is published to config/opensearch-migrations.php:

'table' => env('OPENSEARCH_MIGRATIONS_TABLE', 'opensearch_migrations'),

'connection' => env('OPENSEARCH_MIGRATIONS_CONNECTION'),

'storage_directory' => env('OPENSEARCH_MIGRATIONS_DIRECTORY', base_path('opensearch/migrations')),

'index_name_prefix' => env('OPENSEARCH_MIGRATIONS_INDEX_NAME_PREFIX', env('SCOUT_PREFIX', '')),

'alias_name_prefix' => env('OPENSEARCH_MIGRATIONS_ALIAS_NAME_PREFIX', env('SCOUT_PREFIX', '')),

Creating Migrations

Create a migration:

php artisan opensearch:make:migration create_posts_index

Migration files are stored in opensearch/migrations by default:

use DirectoryTree\OpenSearchAdapter\Indices\Mapping;
use DirectoryTree\OpenSearchAdapter\Indices\Settings;
use DirectoryTree\OpenSearchMigrations\Facades\Index;
use DirectoryTree\OpenSearchMigrations\MigrationInterface;

class CreatePostsIndex implements MigrationInterface
{
    public function up(): void
    {
        Index::create('posts', function (Mapping $mapping, Settings $settings) {
            $mapping->text('title');
            $mapping->text('body');
        });
    }

    public function down(): void
    {
        Index::dropIfExists('posts');
    }
}

Running Migrations

Run all pending migrations:

php artisan opensearch:migrate

Run a single migration:

php artisan opensearch:migrate 2026_01_01_000000_create_posts_index

Roll back the last batch:

php artisan opensearch:migrate:rollback

Roll back every migrated file:

php artisan opensearch:migrate:reset

Roll back and rerun every migration:

php artisan opensearch:migrate:refresh

Drop all indexes and rerun every migration:

php artisan opensearch:migrate:fresh

Show migration status:

php artisan opensearch:migrate:status

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固