PHPackages                             clear01/doctrine-migrations - 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. clear01/doctrine-migrations

ActiveLibrary[Database &amp; ORM](/categories/database)

clear01/doctrine-migrations
===========================

Implementation of Doctrine Migrations to Nette

v4.4.0(6y ago)05.6k↓33.3%MITPHPPHP ^7.0

Since Aug 16Pushed 4y ago2 watchersCompare

[ Source](https://github.com/clear01/DoctrineMigrations)[ Packagist](https://packagist.org/packages/clear01/doctrine-migrations)[ RSS](/packages/clear01-doctrine-migrations/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (13)Versions (51)Used By (0)

Doctrine Migrations
===================

[](#doctrine-migrations)

[![Build Status](https://camo.githubusercontent.com/8af1f296719500ed9cd61c74c640b02478e53a9f7cde4a62de6507f2a0b845d0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f5a656e6966792f446f637472696e654d6967726174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Zenify/DoctrineMigrations)[![Quality Score](https://camo.githubusercontent.com/d46df8fc28c211e9f4076da2ff1768ad1ffd03993d41f532404c80e62fbec244/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f5a656e6966792f446f637472696e654d6967726174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Zenify/DoctrineMigrations)[![Code Coverage](https://camo.githubusercontent.com/f7700f1379ec9b84b8bce79b1e296c8795180fdb2da489206551e11370ec1969/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f5a656e6966792f446f637472696e654d6967726174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Zenify/DoctrineMigrations)[![Downloads this Month](https://camo.githubusercontent.com/b9edfcbb6a3d9a20f0787beccf5e1d669a7a7cd3c593331e1a762ae13f11a3c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a656e6966792f646f637472696e652d6d6967726174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zenify/doctrine-migrations)[![Latest stable](https://camo.githubusercontent.com/fb1c65ddb5a8cc9b5d12f807e79f4a2a304142d49059f8784ec99ef088bbc651/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a656e6966792f646f637472696e652d6d6967726174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zenify/doctrine-migrations)

Implementation of [Doctrine\\Migrations](http://docs.doctrine-project.org/projects/doctrine-migrations/en/latest/) to Nette.

Install
-------

[](#install)

```
composer require zenify/doctrine-migrations
```

Register extensions in `config.neon`:

```
extensions:
	- Arachne\ContainerAdapter\DI\ContainerAdapterExtension
	- Arachne\EventDispatcher\DI\EventDispatcherExtension
	migrations: Zenify\DoctrineMigrations\DI\MigrationsExtension

	# Kdyby\Doctrine or another Doctrine integration
	doctrine: Kdyby\Doctrine\DI\OrmExtension
```

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

[](#configuration)

`config.neon` with default values

```
migrations:
	table: doctrine_migrations # database table for applied migrations
	column: version # database column for applied migrations
	directory: %appDir%/../migrations # directory, where all migrations are stored
	namespace: Migrations # namespace of migration classes
	codingStandard: tabs # or "spaces", coding style for generated classes
	versionsOrganization: null # null, "year" or "year_and_month", organizes migrations to subdirectories
```

Usage
-----

[](#usage)

Open your CLI and run command (based on `Kdyby\Console` integration):

```
php www/index.php
```

And then you should see all available commands:

[![CLI commands](cli-commands.png)](cli-commands.png)

### Migrate changes to database

[](#migrate-changes-to-database)

If you want to migrate existing migration to your database, just run migrate commmand:

```
php www/index.php migrations:migrate
```

If you get lost, just use `-h` option for help:

```
php www/index.php migrations:migrate -h
```

### Create new migration

[](#create-new-migration)

To create new empty migration, just run:

```
php www/index.php migrations:generate
```

A new empty migration will be created at your migrations directory. You can add your sql there then.

Migration that would add new role `"superadmin"` to `user_role` table would look like this:

```
namespace Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
 * New role "superadmin" added.
 */
final class Version20151015000003 extends AbstractMigration
{

	public function up(Schema $schema)
	{
		$this->addSql("INSERT INTO 'user_role' (id, value, name) VALUES (3, 'superadmin', 'Super Admin')");
	}

	public function down(Schema $schema)
	{
		$this->addSql("DELETE FROM 'user_role' WHERE ('id' = 3);");
	}

}
```

Simple as that!

For further use, please check [docs in Symfony bundle](http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html).

Features
--------

[](#features)

### Migrations organization

[](#migrations-organization)

If you have over 100 migrations in one directory, it might get messy. Fortunately doctrine migrations can organize your migrations to directories by year or by year and month. You can configure it in your config.neon (see above).

```
/migrations/2015/11
	- VersionXXX.php
/migrations/2015/12
	- VersionYYY.php
/migrations/2016/01
	- VersionZZZ.php

```

### Injected migrations

[](#injected-migrations)

Note: this is not really best practise, so try to use it only if there is no other way.

```
namespace Migrations;

final class Version20140801152432 extends AbstractMigration
{

	/**
	 * @inject
	 * @var Doctrine\ORM\EntityManagerInterface
	 */
	public $entityManager;

	public function up(Schema $schema)
	{
		// ...
	}

	// ...

}
```

Testing
-------

[](#testing)

```
composer check-cs
vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Rules are simple:

- new feature needs tests
- all tests must pass
- 1 feature per PR

We would be happy to merge your feature then!

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 55.6% 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 ~55 days

Recently: every ~252 days

Total

35

Last Release

2457d ago

Major Versions

v0.9.2 → v1.0.02014-11-22

v1.0.0 → v2.0.02014-12-10

v2.3.5 → v3.0.02016-09-23

v3.0.0 → v4.12016-12-28

PHP version history (5 changes)v0.1.0PHP &gt;=5.4

v2.0.0PHP &gt;=5.5

v2.2.0PHP &gt;=5.6

v2.3.4PHP ^5.6|^7.0

v4.1PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4654a37d044029106ae0e3864278dd691d834fb972e693441e35ccae592c2e28?d=identicon)[clear01](/maintainers/clear01)

---

Top Contributors

[![martinknor](https://avatars.githubusercontent.com/u/2004222?v=4)](https://github.com/martinknor "martinknor (5 commits)")[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/clear01-doctrine-migrations/health.svg)

```
[![Health](https://phpackages.com/badges/clear01-doctrine-migrations/health.svg)](https://phpackages.com/packages/clear01-doctrine-migrations)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M712](/packages/sylius-sylius)[sulu/sulu

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

1.3k1.4M196](/packages/sulu-sulu)[bartlett/php-compatinfo-db

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

1184.5k2](/packages/bartlett-php-compatinfo-db)

PHPackages © 2026

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