PHPackages                             doesntmattr/mongodb-migrations-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. doesntmattr/mongodb-migrations-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

doesntmattr/mongodb-migrations-bundle
=====================================

Symfony MongoDBMigrationsBundle

v3.0.1(6y ago)23487.9k↓36.3%27[3 issues](https://github.com/doesntmattr/mongodb-migrations-bundle/issues)[2 PRs](https://github.com/doesntmattr/mongodb-migrations-bundle/pulls)1MITPHPPHP ^7.1CI failing

Since Sep 26Pushed 5y ago7 watchersCompare

[ Source](https://github.com/doesntmattr/mongodb-migrations-bundle)[ Packagist](https://packagist.org/packages/doesntmattr/mongodb-migrations-bundle)[ Docs](http://github.com/doesntmattr/mongodb-migrations-bundle)[ RSS](/packages/doesntmattr-mongodb-migrations-bundle/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (6)Versions (10)Used By (1)

[![MIT license](https://camo.githubusercontent.com/4661abfe916186acde514558e7f040833cb63ba7098401a51ce339cbb2b4cf9e/687474703a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](http://opensource.org/licenses/MIT)[![Build Status](https://camo.githubusercontent.com/81064633db9ff71504c9733f82616db02c5fcbfe4fcf18f18519ed1ae1ab4fed/68747470733a2f2f7472617669732d63692e6f72672f646f65736e746d617474722f6d6f6e676f64622d6d6967726174696f6e732d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/doesntmattr/mongodb-migrations-bundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/61b8b1c865ecc3a0c0b8316268b9e527fd844d2bc8f3a854ffe4d793f83cc678/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f646f65736e746d617474722f6d6f6e676f64622d6d6967726174696f6e732d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/doesntmattr/mongodb-migrations-bundle/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/657faa7bf1e4323728c3594987edb3f1f5c632e13973c6c002122461988bbdc4/68747470733a2f2f706f7365722e707567782e6f72672f646f65736e746d617474722f6d6f6e676f64622d6d6967726174696f6e732d62756e646c652f762f737461626c65)](https://packagist.org/packages/doesntmattr/mongodb-migrations-bundle)[![Total Downloads](https://camo.githubusercontent.com/5706d7bb217878487d900045c27657b5878a088f70c91b8f3b01fc4de248dfb2/68747470733a2f2f706f7365722e707567782e6f72672f646f65736e746d617474722f6d6f6e676f64622d6d6967726174696f6e732d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/doesntmattr/mongodb-migrations-bundle)

MongoDB Migrations Bundle
=========================

[](#mongodb-migrations-bundle)

This bundle integrates the [MongoDB Migrations](https://github.com/doesntmattr/mongodb-migrations) library into Symfony to get you set up more quickly.

It was moved to the doesntmattr organisation from [antimattr/mongodb-migrations-bundle](https://github.com/antimattr/mongodb-migrations-bundle) to continue maintenance (See [issue 16](https://github.com/antimattr/mongodb-migrations/issues/16)).

The original authors are @rcatlin and @matthewfitz

PHP Version Support
-------------------

[](#php-version-support)

If you require php 5.6 support use version `^1.0`. Version `^3.0` requires at least php 7.1. The `1.x` releases will only receive bug fixes.

Installation
------------

[](#installation)

Install with composer:

```
# For php 5.6
composer require "doesntmattr/mongodb-migrations-bundle=^1.0"

# For php 7.1
composer require "doesntmattr/mongodb-migrations-bundle=^3.0"
```

then enable the bundle in `AppKernel.php` by including the following:

```
// app/AppKernel.php
public function registerBundles()
{
    $bundles = [
        //...
        new AntiMattr\Bundle\MongoDBMigrationsBundle\MongoDBMigrationsBundle(),
    ];
}
```

Configuration
-------------

[](#configuration)

Add following configuration lines to `config.yml` file.

```
# app/config/config.yml
mongo_db_migrations:
    collection_name: "migration_versions"
    database_name: "opensky_devo"
    dir_name: "%kernel.project_dir%/src/OpenSky/Bundle/MainBundle/Migrations/MongoDB"
    script_dir_name: "%kernel.project_dir%/scripts"
    name: "OpenSky DEVO MongoDB Migrations"
    namespace: "OpenSky\\Bundle\\MainBundle\\MigrationsMongoDB"
```

Container Aware Migrations
--------------------------

[](#container-aware-migrations)

In some cases you might want to access some services you have defined in the container. For example you may want to use a Factory to create new entities in the structure you need.

To get access to the container simply implement the ContainerAwareInterface including the required method `setContainer()`:

```
// ...
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class Version20130326212938 extends AbstractMigration implements ContainerAwareInterface
{
    private $container;

    public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
    }

    public function up(Database $db)
    {
        // ... migration content
    }

    public function postUp(Database $db)
    {
        $dm = $this->container->get('doctrine.odm.default_document_manager');
        // ... update the entities
    }
}
```

MongoDB Cursor Timeouts
-----------------------

[](#mongodb-cursor-timeouts)

In some cases you may need the Cursor timeout to be extended. If so, add the MongoDB option `['socketTimeoutMs' => -1]` to your update method.

Features
--------

[](#features)

For a full list of available features, see the README.md in the MongoDB Migrations library:

Differences from the underlying library are limited to the Console commands, namely database configurations are handled by Symfony's Dependency injection container, so you don't pass them as command line args.

Examples of the Command Line args with the difference below:

### Generate a New Migration

[](#generate-a-new-migration)

```
> ./console mongodb:migrations:generate
Generated new migration class to "Example/Migrations/TestAntiMattr/MongoDB/Version20140822185742.php"
```

### Status of Migrations

[](#status-of-migrations)

```
> ./console mongodb:migrations:status

 == Configuration

    >> Name:                                AntiMattr Example Migrations
    >> Database Driver:                     MongoDB
    >> Database Name:                       test_antimattr_migrations
    >> Configuration Source:                demo/ConsoleApplication/config/test_antimattr_mongodb.yml
    >> Version Collection Name:             migration_versions
    >> Migrations Namespace:                Example\Migrations\TestAntiMattr\MongoDB
    >> Migrations Directory:                Example/Migrations/TestAntiMattr/MongoDB
    >> Current Version:                     0
    >> Latest Version:                      2014-08-22 18:57:44 (20140822185744)
    >> Executed Migrations:                 0
    >> Executed Unavailable Migrations:     0
    >> Available Migrations:                3
    >> New Migrations:                      3
```

### Migrate all Migrations

[](#migrate-all-migrations)

This is what you will execute during your deployment process.

```
./console mongodb:migrations:migrate

                    AntiMattr Example Migrations

WARNING! You are about to execute a database migration that could result in data lost. Are you sure you wish to continue? (y/n)y
Migrating up to 20140822185744 from 0

  ++ migrating 20140822185742

     Collection test_a

     metric           before               after                difference
     ================================================================================
     count            100                  100                  0
     size             20452                20452                0
     avgObjSize       204.52               204.52               0
     storageSize      61440                61440                0
     numExtents       2                    2                    0
     nindexes         1                    2                    1
     lastExtentSize   49152                49152                0
     paddingFactor    1                    1                    0
     totalIndexSize   8176                 16352                8176

  ++ migrated (0.03s)

  ++ migrating 20140822185743

  ++ migrated (0s)

  ++ migrating 20140822185744

  ++ migrated (0s)

  ------------------------

  ++ finished in 0.03
  ++ 3 migrations executed
```

### Execute a Single Migration

[](#execute-a-single-migration)

```
./console mongodb:migrations:execute 20140822185742
WARNING! You are about to execute a database migration that could result in data lost. Are you sure you wish to continue? (y/n)y

  ++ migrating 20140822185742

     Collection test_a

     metric           before               after                difference
     ================================================================================
     count            100                  100                  0
     size             20620                20620                0
     avgObjSize       206.2                206.2                0
     storageSize      61440                61440                0
     numExtents       2                    2                    0
     nindexes         1                    2                    1
     lastExtentSize   49152                49152                0
     paddingFactor    1                    1                    0
     totalIndexSize   8176                 16352                8176

  ++ migrated (0.02s)
```

Use `--replay` if you need to re-run an executed migration.

### Version Up or Down

[](#version-up-or-down)

Is your migration history out of sync for some reason? You can manually add or remove a record from the history without running the underlying migration.

You can delete

```
./console mongodb:migrations:version --delete 20140822185744
```

You can add

```
./console mongodb:migrations:version --add 20140822185744
```

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~255 days

Recently: every ~191 days

Total

9

Last Release

2255d ago

Major Versions

1.2.0 → 2.02018-04-12

v2.0.1 → 3.0.02020-03-21

PHP version history (3 changes)v1.0.0PHP &gt;=5.3.2

1.2.0PHP &gt;=5.6 || ^7.0

2.0PHP ^7.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3765656?v=4)[Catalin Ciobanu](/maintainers/caciobanu)[@caciobanu](https://github.com/caciobanu)

![](https://avatars.githubusercontent.com/u/767896?v=4)[Douglas Reith](/maintainers/redthor)[@redthor](https://github.com/redthor)

---

Top Contributors

[![redthor](https://avatars.githubusercontent.com/u/767896?v=4)](https://github.com/redthor "redthor (36 commits)")[![matthewfitz](https://avatars.githubusercontent.com/u/208401?v=4)](https://github.com/matthewfitz "matthewfitz (20 commits)")[![caciobanu](https://avatars.githubusercontent.com/u/3765656?v=4)](https://github.com/caciobanu "caciobanu (16 commits)")[![arendjantetteroo](https://avatars.githubusercontent.com/u/713066?v=4)](https://github.com/arendjantetteroo "arendjantetteroo (5 commits)")[![emulienfou](https://avatars.githubusercontent.com/u/84061?v=4)](https://github.com/emulienfou "emulienfou (2 commits)")[![tychris](https://avatars.githubusercontent.com/u/7794059?v=4)](https://github.com/tychris "tychris (1 commits)")[![graillus](https://avatars.githubusercontent.com/u/4977244?v=4)](https://github.com/graillus "graillus (1 commits)")[![JoppeDC](https://avatars.githubusercontent.com/u/9723620?v=4)](https://github.com/JoppeDC "JoppeDC (1 commits)")[![trq](https://avatars.githubusercontent.com/u/32683?v=4)](https://github.com/trq "trq (1 commits)")

---

Tags

migrate-databasemigrationsmongodbphpsymfonysymfony-bundlesymfonymigrationdatabasedoctrinemongodbantimattrdoesntmattr

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/doesntmattr-mongodb-migrations-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/doesntmattr-mongodb-migrations-bundle/health.svg)](https://phpackages.com/packages/doesntmattr-mongodb-migrations-bundle)
```

###  Alternatives

[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[doesntmattr/mongodb-migrations

Managed Database Migrations for MongoDB

23612.1k1](/packages/doesntmattr-mongodb-migrations)[ecotone/symfony-bundle

Ecotone for Symfony — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Symfony Messenger, via PHP attributes.

11249.0k1](/packages/ecotone-symfony-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

9410.7k](/packages/ahmed-bhs-doctrine-doctor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
