PHPackages                             roslov/migration-checker-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. roslov/migration-checker-bundle

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

roslov/migration-checker-bundle
===============================

Up/down database migration checker for Symfony

1.0.0(3mo ago)0136[4 issues](https://github.com/roslov/migration-checker-bundle/issues)MITPHPPHP ^8.1CI passing

Since Jan 2Pushed 3mo agoCompare

[ Source](https://github.com/roslov/migration-checker-bundle)[ Packagist](https://packagist.org/packages/roslov/migration-checker-bundle)[ RSS](/packages/roslov-migration-checker-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (13)Used By (0)

Database Migration Checker Bundle
=================================

[](#database-migration-checker-bundle)

[![Latest Stable Version](https://camo.githubusercontent.com/70dfad8d3de6a3f7fd145ddf949f6f27e05058424d1a616421fed615d718f9ef/68747470733a2f2f706f7365722e707567782e6f72672f726f736c6f762f6d6967726174696f6e2d636865636b65722d62756e646c652f76)](https://packagist.org/packages/roslov/migration-checker-bundle)[![Total Downloads](https://camo.githubusercontent.com/72baef92517c957ecc98b809a7a0d84a0a3d927f3388bf04756e00e86d9471b1/68747470733a2f2f706f7365722e707567782e6f72672f726f736c6f762f6d6967726174696f6e2d636865636b65722d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/roslov/migration-checker-bundle)[![License](https://camo.githubusercontent.com/71dce66b891c438d8017cee522a353cf3b8397218330c1c6f75d9f599c5ed27d/68747470733a2f2f706f7365722e707567782e6f72672f726f736c6f762f6d6967726174696f6e2d636865636b65722d62756e646c652f6c6963656e7365)](https://packagist.org/packages/roslov/migration-checker-bundle)[![PHP Version Require](https://camo.githubusercontent.com/ad2ecc35b9ec82be50d83e539d10242577da6c52253ceadf3092555a1acb0ee9/68747470733a2f2f706f7365722e707567782e6f72672f726f736c6f762f6d6967726174696f6e2d636865636b65722d62756e646c652f726571756972652f706870)](https://packagist.org/packages/roslov/migration-checker-bundle)

The Database Migration Checker Bundle validates Doctrine Migrations in Symfony by executing each migration up and down against a clean test database and ensuring the schema returns to the exact same state after the rollback. It wraps the core [Migration Checker](https://github.com/roslov/migration-checker) library and provides a ready-to-use Symfony console command.

This is intended for CI pipelines and local checks where you want confidence that every migration can be applied and reverted without leaving stray tables, columns, or indexes behind.

Requirements
------------

[](#requirements)

- PHP 8.1 or higher,
- Symfony 6.0 or higher,
- Doctrine Migrations Bundle 3.2.1 or higher,
- Doctrine ORM 2.0 or higher.

Supported database types and versions
-------------------------------------

[](#supported-database-types-and-versions)

This bundle supports MySQL, MariaDB, PostgreSQL, and others.

See all supported database types and versions in the [Migration Checker documentation](https://github.com/roslov/migration-checker#supported-database-types-and-versions).

Limitations
-----------

[](#limitations)

The console command `migration-checker:check` runs only in the test environment to avoid accidentally affecting the working database. Therefore, it should always be used with the option `--env=test`.

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

[](#installation)

The package could be installed with composer:

```
composer require --dev roslov/migration-checker-bundle
```

If you are not using Symfony Flex, register the bundle manually:

```
// config/bundles.php
return [
    // ...
    Roslov\MigrationCheckerBundle\RoslovMigrationCheckerBundle::class => ['dev' => true, 'test' => true],
];
```

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

[](#configuration)

If you have a custom Doctrine setup, you can configure the entity manager and the migrations dependency factory. Create a configuration file `config/packages/roslov_migration_checker.yaml`:

```
roslov_migration_checker:
    # Doctrine entity manager name.
    # Default: 'default' (uses 'doctrine.orm.default_entity_manager')
    entity_manager: 'default'

    # Doctrine Migrations dependency factory service ID.
    # Default: 'doctrine.migrations.dependency_factory'
    dependency_factory: 'doctrine.migrations.dependency_factory'
```

General usage
-------------

[](#general-usage)

### What the checker does

[](#what-the-checker-does)

For each new Doctrine migration, the checker will:

1. Apply the migration (up).
2. Roll it back (down).
3. Compare the database schema before and after to ensure they match.
4. Re-apply the migration to proceed to the next one.

If the schema differs after a rollback, the command fails and prints a unified diff of the schema changes.

### Prerequisites

[](#prerequisites)

To get useful results, make sure:

- The command is executed in the **test** environment (`--env=test`).
- Your test database is **empty** before the run (fresh schema).
- Doctrine Migrations is configured for the same connection your test environment uses.

### Run locally

[](#run-locally)

You can run the command to check your migrations:

```
php bin/console migration-checker:check --env=test -vv
```

Be careful to run it in the test environment, otherwise you can damage your data.

Also, ensure that you run this command on an empty database each time.

### Successful output example

[](#successful-output-example)

```
[info] Migration check started.
[info] Preparing migration environment...
[info] Checking if another migration can be applied...
[info] Saving the current state...
[info] Applying the up migration...
[info] Applying the up migration "DoctrineMigrations\Version20241105145435"...
[info] Applying the down migration...
[info] Applying the down migration "DoctrineMigrations\Version20241105145435"...
[info] Saving the state after up and down migrations...
[info] Comparing the states...
[info] The up and down migrations have been applied successfully without any state changes.
[info] Applying the up migration before the next step...
[info] Applying the up migration "DoctrineMigrations\Version20241105145435"...
[info] Checking if another migration can be applied...
[info] There are no migrations available.
[info] Cleaning up migration environment...
[info] Migration check completed successfully.

```

### Failed output example

[](#failed-output-example)

```
[info] Migration check started.
[info] Preparing migration environment...
[info] Checking if another migration can be applied...
[info] Saving the current state...
[info] Applying the up migration...
[info] Applying the up migration "DoctrineMigrations\Version20241105145435"...
[info] Applying the down migration...
[info] Applying the down migration "DoctrineMigrations\Version20241105145435"...
[info] Saving the state after up and down migrations...
[info] Comparing the states...
[error] The down migration has resulted in a different schema state after rollback.
--- Original
+++ New
@@ @@
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

+-- Table:
+event
+
+-- Create Table:
+CREATE TABLE `event` (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT,
+  `microtime` double(16,6) NOT NULL COMMENT 'Unix timestamp with microseconds',
+  `producer_name` varchar(64) NOT NULL COMMENT 'Producer name',
+  `body` varchar(4096) NOT NULL COMMENT 'Full message body',
+  `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Creation timestamp',
+  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Update timestamp',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Events (transactional outbox)'
+
+
 -- ### Triggers ###

In MigrationChecker.php line 67:

  [Roslov\MigrationChecker\Exception\SchemaDiffersException]
  The up and down migrations have resulted in a different schema state after rollback.

```

### Run in CI

[](#run-in-ci)

The following example spins up a MySQL container, waits for it to be ready, runs the check, and then cleans up. Adjust database credentials and the image name to match your project.

If you want to run it in your CI, you can do something like this:

```
# Stops the previously running test environment and database (if the previous run failed)
docker stop test-db || true
docker network rm test-network || true
# Prepares the new test environment
docker network create test-network
# Starts the test database
docker run --name test-db --network=test-network -d --rm \
    -e MYSQL_ROOT_PASSWORD=testrootpass \
    -e MYSQL_DATABASE=test \
    -e MYSQL_USER=testuser \
    -e MYSQL_PASSWORD=testpass \
    mysql:8.4.5 --character-set-server=utf8mb4 --collation-server=utf8mb4_0900_ai_ci
# Waits until the database is ready
while ! docker exec test-db \
    mysql --user=testuser --password=testpass \
    -e 'SELECT 1' \
    >/dev/null 2>&1; do
    echo 'Waiting for database connection...'
    sleep 1
done
# Runs the migration check.
# This command should fail if there are problems with migrations
docker run --network=test-network --rm \
    your-project-image:latest \
    php bin/console migration-checker:check --env=test -vv
# Stops the test database
docker stop test-db
# Stops the test environment
docker network rm test-network
```

Testing
-------

[](#testing)

### Unit testing

[](#unit-testing)

The package is tested with [PHPUnit](https://phpunit.de/). To run tests:

```
./vendor/bin/phpunit
```

inside a container, or

```
make test
```

### Code style analysis

[](#code-style-analysis)

The code style is analyzed with [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) and [PSR-12 Ext coding standard](https://github.com/roslov/psr12ext). To run code style analysis:

```
./vendor/bin/phpcs --extensions=php --colors --standard=PSR12Ext --ignore=vendor/* -p -s .
```

inside a container, or

```
make phpcs
```

from the host machine.

### Static analysis

[](#static-analysis)

Static analysis is performed with [PHPStan](https://phpstan.org/). To run it:

```
./vendor/bin/phpstan analyse --memory-limit=256M .
```

inside a container, or

```
make phpstan
```

from the host machine.

### Full validation

[](#full-validation)

To run all checks (PHP syntax, coding style, PHPStan, and Rector) at once:

```
make validate
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance82

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~4 days

Total

11

Last Release

92d ago

Major Versions

0.5.0 → 1.0.02026-02-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/464fc58072b48a348a355eeca35b6fe2e341fd494b4ffb8e30f2007c3a2a6ad5?d=identicon)[tr](/maintainers/tr)

---

Top Contributors

[![roslov](https://avatars.githubusercontent.com/u/6573063?v=4)](https://github.com/roslov "roslov (20 commits)")

---

Tags

symfonybundledevmigrationdatabasedownUp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/roslov-migration-checker-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/roslov-migration-checker-bundle/health.svg)](https://phpackages.com/packages/roslov-migration-checker-bundle)
```

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[kreait/firebase-bundle

Symfony Bundle for the Firebase Admin SDK

1534.7M2](/packages/kreait-firebase-bundle)[bartlett/php-compatinfo-db

Reference Database of all functions, constants, classes, interfaces on PHP standard distribution and about 110 extensions

1183.0k1](/packages/bartlett-php-compatinfo-db)

PHPackages © 2026

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