Elastic Migrations
Versioned, artisan-driven Elasticsearch index migrations for Laravel.
Repository Health
Technical Analysis
Elastic Migrations brings the familiar Laravel database-migration workflow to Elasticsearch. Instead of managing index mappings and settings by hand, you write versioned migration classes that create, update, or drop indices, then apply and roll them back with artisan commands.
The package tracks which migrations have run in a repository, exposes an index manager for common operations like creating indices, updating mappings, and configuring settings, and integrates with Laravel’s service container through a dedicated service provider. Built on the elastic-adapter layer, it keeps Elasticsearch schema changes reproducible and version-controlled alongside application code.
What You Get
- Versioned migration classes for Elasticsearch indices
- Artisan commands to run, roll back, and reset migrations
- An index manager for creating indices and updating mappings and settings
- A migration repository that tracks applied versions
- Laravel service-provider integration and facades
Common Use Cases
- Versioning Elasticsearch index mappings alongside application code
- Rolling out mapping or settings changes across environments reproducibly
- Rebuilding or resetting search indices during deploys
Under The Hood
Architecture - A central Migrator (in the Elastic\Migrations namespace) coordinates a MigrationStorage that discovers migration files on the filesystem, a MigrationFactory that instantiates them, and a MigrationRepository that records which have been applied. Console commands drive migrateOne/migrateAll/rollback flows, while an IndexManager (backed by babenkoivan/elastic-adapter) performs the actual create/update/drop operations against Elasticsearch. A ServiceProvider wires everything into Laravel’s container and registers facades.
Tech Stack - Pure PHP (php ^8.2) with strict types, depending on babenkoivan/elastic-adapter ^5.0 for Elasticsearch access and Laravel’s Illuminate console/support components. PSR-4 autoloaded, distributed via Packagist, with GitHub Actions running the test and code-style workflows.
Code Quality - The code uses declared strict types, small single-responsibility classes, and interfaces (MigrationInterface, IndexManagerInterface, ReadinessInterface) that make the moving parts explicit and testable. Errors surface as readable console output, and the project ships a maintained test suite; recent commit activity is low, consistent with a stable, feature-complete package.
API Design - The developer experience deliberately mirrors Laravel’s own migrations: generate a migration class, implement up()/down() using the injected index manager, and run artisan commands. That familiarity means Laravel developers need almost no new mental model, and the facade plus auto-registered service provider keep setup to a single install step.