- How do I install this package in a Laravel project?
- Run `composer require doesntmattr/mongodb-migrations` for PHP 7.1+. For PHP 5.6, use `composer require doesntmattr/mongodb-migrations:^1.0`. Ensure the `mongodb/mongodb` PHP extension (v1.0+) is installed via `pecl install mongodb`.
- Does this package integrate with Laravel’s `php artisan migrate` command?
- No, this package does not integrate natively with Laravel’s migration system. You’ll need to create a custom Artisan command or wrapper script to trigger migrations, as it lacks built-in artisan support.
- Which Laravel versions are officially supported?
- The package does not explicitly list Laravel version support, but it requires PHP 7.1+ (for v3.0) or PHP 5.6 (for v1.0). Test compatibility with Laravel 8.0+ by verifying the `mongodb/mongodb` extension works in your environment.
- Can I use this for data migrations (e.g., transforming existing documents)?
- Yes, but rollback support is basic. For complex data migrations, implement pre-migration backups or dry-run modes. Manual intervention may be required for irreversible changes.
- How do I configure MongoDB connection settings?
- Create a PHP config file (e.g., `test_antimattr_mongodb.php`) with `host`, `port`, `dbname`, `user`, `password`, and `options` arrays. The package follows Doctrine Migrations’ connection format.
- Is there a way to test migrations before deploying to production?
- No built-in dry-run mode exists. Manually validate migrations by running them against a staging database or using MongoDB’s `mongosh` to inspect changes before deployment.
- What’s the difference between this and `jenssegers/laravel-mongodb`?
- `jenssegers/laravel-mongodb` integrates with Eloquent and Laravel’s migration system, offering tighter Laravel ecosystem support. This package is standalone and better suited for non-Eloquent MongoDB workflows.
- How do I handle migrations in a CI/CD pipeline?
- Wrap migrations in a custom Artisan command or script. Trigger them post-deployment or during a maintenance window. For zero-downtime needs, use MongoDB’s write concern and transactions (v4.0+).
- Are there any known issues with concurrent migrations?
- Concurrency risks exist if multiple processes run migrations simultaneously. Use MongoDB’s write concern settings or transactions (v4.0+) to mitigate conflicts. Avoid overlapping schema changes.
- Can I use this for schema-only migrations (e.g., adding indexes) without touching data?
- Yes, this package excels at schema migrations like creating collections, adding indexes, or modifying document structures. For data-only changes, consider custom scripts or MongoDB’s `updateMany` operations.