Latest release: v0.3

Migrations

Content

Usage

At first you should register MigrationsExtension at your config file.

extensions:
    migrations: Nettrine\Migrations\DI\MigrationsExtension
1
2

This extension is highly depending on Symfony\Console, it does not make sence to use it without Console. Take a look at simple Contributte/Console integration.

composer require contributte/console
1
extensions:
    console: Contributte\Console\DI\ConsoleExtension
1
2

Configuration

Default configuration looks like this:

migrations:
    table: doctrine_migrations 
    column: version
    directory: %appDir%/../migrations
    namespace: Migrations
    versionsOrganization: null # null, year, year_and_month
1
2
3
4
5
6

Kdyby/Doctrine

If you want to use Kdyby/Doctrine, please use this additional configuration:

decorator:
    Symfony\Component\Console\Command\Command:
        tags: [kdyby.console.command]
    Symfony\Component\Console\Helper\Helper:
        tags: [kdyby.console.helper]
1
2
3
4
5

Commands

Type bin/console in your terminal and there should be a migrations command group.

commands

Dependency Injection

It is possible to use either @inject annotation or inject*() methods on migration classes:

/**
 * @var MyService
 * @inject
 */
public $myService;
1
2
3
4
5
/**
 * @var MyService
 */
private $myService;

public function injectMyService(MyService $myService): void
{
    $this->myService = $myService;
}
1
2
3
4
5
6
7
8
9

Read more at official Nette documentation.