Weave Code
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
Mongodb Migrations

Mongodb Migrations Laravel Package

devture/mongodb-migrations

Laravel-friendly MongoDB migration runner that manages schema/data changes with versioned migration classes and CLI commands. Helps apply, track, and rollback database updates across environments in a predictable way.

View on GitHub
Deep Wiki
Context7

Managed migration support for MongoDB

Frequently asked questions about Mongodb Migrations
How do I install and set up devture/mongodb-migrations in a Laravel project?
Run `composer require devture/mongodb-migrations` to install the package. Configure MongoDB connection settings in a PHP file (e.g., `test_antimattr_mongodb.php`) with host, port, credentials, and database name. Then, define migrations in XML or YAML format, following the Doctrine Migrations structure.
Does this package support Laravel 9 or 10? What’s the latest PHP version requirement?
The package is compatible with Laravel 8+ and PHP 8.0+. Version 4.x requires PHP 8.0+, while older versions (e.g., 1.x) support PHP 5.6. Always check the latest release notes on Packagist for Laravel version-specific updates.
Can I use this for both schema changes (e.g., adding indexes) and data migrations (e.g., updating documents)?
Yes, the package supports both schema and data migrations. Use methods like `createCollection`, `addField`, or `dropIndex` for schema changes, and `insert`, `updateMany`, or `delete` for data operations. Rollbacks are also supported for both types.
How do I run migrations for MongoDB alongside Laravel’s SQL migrations?
Use `php artisan migrate` as usual—it will execute both SQL and MongoDB migrations. The package integrates with Laravel’s migration system, so no additional commands are needed. Ensure your MongoDB connection is configured in `config/database.php`.
What happens if a migration fails mid-execution? Can I roll back partially applied changes?
The package tracks migrations in a `migrations` table (like Laravel’s SQL migrations) but does not natively support atomic rollbacks for MongoDB due to its lack of multi-document transactions. Test rollbacks thoroughly, especially for data-heavy migrations, and consider backing up collections before risky operations.
Is there a way to check which MongoDB migrations have already been run?
No direct GUI like Laravel’s `migrate:status`, but you can inspect the `migrations` table or use CLI commands like `php artisan migrate:status` (for SQL) alongside manual checks for MongoDB-specific migrations. The package logs executed migrations in the database.
How do I handle initial migrations for existing MongoDB collections in production?
For existing collections, avoid `Schema::createCollection` and use `Schema::table` or custom logic to inspect and adapt the schema. Document the current state manually, then create a migration to align it with your desired schema. Use `addField` with defaults or `updateMany` for data adjustments.
Are there performance concerns when running large data migrations in production?
Yes, migrations with bulk operations (e.g., `updateMany` on millions of documents) can impact performance. Test in staging first, and consider batching operations or running during low-traffic periods. Monitor MongoDB logs for slow queries or timeouts.
Can I use this package with MongoDB Atlas or other cloud providers?
Absolutely. Configure the connection settings in your PHP file to use the Atlas connection string (e.g., `mongodb+srv://...`) or other cloud-specific endpoints. Ensure your credentials and network settings (e.g., IP whitelisting) are properly configured.
What alternatives exist for MongoDB migrations in Laravel, and why choose this package?
Alternatives include raw MongoDB PHP driver scripts or custom solutions using Laravel’s `Schema::table` methods. This package stands out for its Laravel integration (Artisan commands, rollbacks, versioning) and Doctrine Migrations compatibility, reducing boilerplate and leveraging familiar workflows.
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity