Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Opensearch Migrations Laravel Package

directorytree/opensearch-migrations

OpenSearch index migrations for Laravel. Create, configure, and run versioned index migrations with a familiar artisan workflow, including mappings, settings, index and alias prefixes, and publishing config files.

View on GitHub
Deep Wiki
Context7

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

Credits

This package builds on a lot of the foundation and prior work from Ivan Babenko and his Elasticsearch Laravel ecosystem packages.

We're grateful for the work he has shared with the Laravel community. If this package helps your work, consider supporting Ivan through GitHub Sponsors.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator