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.
Build vs. buy for search infrastructure management. If your product runs on OpenSearch (or Elasticsearch) and you already have a Laravel codebase, this package answers a narrower question than "should we build a search platform": it decides whether index definitions live as reviewed, versioned files in your repo or as undocumented console commands and tribal knowledge. That's a low-commitment build-vs-buy call with outsized operational payoff.
Feature: making index schema a first-class, reviewable artifact. Index mappings are effectively database schema for search. This package lets a PM mandate that any change to how posts is indexed ships through a PR-reviewed migration file, timestamped and reversible, instead of a one-off PUT /posts/_mapping someone ran in March. That directly reduces the class of incident where "search results changed and nobody knows why."
Roadmap sequencing: search features that depend on mapping changes. Any planned feature requiring new indexed fields, changed analyzers, or new indices (facets, filters, relevance tuning, autocomplete) is gated on being able to change mappings safely. This package unblocks that work incrementally — one migration per logical change — rather than forcing a big-bang reindex project.
Multi-environment and multi-tenant readiness. The index_name_prefix / alias_name_prefix config (defaulting to SCOUT_PREFIX) lets one codebase target staging, production, or tenant-scoped indices purely through environment configuration. That's a product capability decision — "can we run a separate search environment per customer or per region?" — made cheap.
Deployment pipeline standardization. Wiring opensearch:migrate immediately after php artisan migrate gives search infrastructure the same deploy discipline, ordering, and log capture as the database. PMs can commit to "search schema is in sync with every deploy" as a policy rather than an aspiration.
Scoping the buy: what this does not solve. Critically, it does not do reindexing, alias swapping for zero-downtime cutover, query building, or search relevance. Those remain product/engineering scope. Adopting this package is buying the index definition component, not a search platform — and the roadmap must reflect that distinction.
Risk management around vendor concentration. The package is a thin wrapper in a single-vendor chain (opensearch-migrations → opensearch-client → official opensearch/php-client), with zero dependents and an early v1.x maturity curve. The PM decision is not just "adopt" but "adopt behind an internal seam" so it can be swapped or vendored without touching application code.
Adopt when all of the following hold:
SCOUT_PREFIX, so existing namespacing carries over for free — no new conventions to teach.Look elsewhere, or scope down, when:
Index::dropIfExists() in down() means rollback removes a live serving index; if nobody will reliably exercise the rollback path, you're carrying risk for little benefit.text → keyword requires a new index plus a reindex. This package won't do it in place, so if that's your primary need, the package is a helper, not a solution.To executives — the one-paragraph version: Search index definitions are schema, and right now ours live in console commands and memory. This package lets us treat them like database migrations: reviewed in PRs, timestamped, reversible, and applied automatically on every deploy. It's a small Composer dependency with no new infrastructure, it's compatible with the prefix scheme we already run in Scout, and it converts a class of "search broke and nobody knows why" incidents into ordinary code review. The trade-off is discipline: we need one migration job in the pipeline, a baseline step for existing indices, and a documented runbook for the case where the migration ledger and the cluster disagree. We should adopt it behind a thin internal interface so we can swap it out if the single-vendor chain stops being maintained.
To engineering — what you're actually signing up for:
opensearch:make:migration scaffolding; a fluent Mapping/Settings API; a familiar six-command set that maps 1:1 onto migrate, :rollback, :reset, :refresh, :fresh, :status; configurable ledger table, connection, storage directory, and index/alias prefixes.opensearch:migrate:fresh away from shared environments — it drops every index.down() is typically dropIfExists; the storage directory must ship with your artifact (post-deploy assertion that it's non-empty); migration filenames are the ledger key, so renaming an applied migration orphans it forever; and at least one CI job must hit a real containerized OpenSearch, because mocks won't catch mapping rejections.Index facade, with a rule that application code never references it directly. That's what makes the vendor-risk answer "we can swap it" rather than "we hope."How can I help you explore Laravel packages today?