Skip to content
Permalink
Branch: master
Find file Copy path
4 contributors

Users who have contributed to this file

@f3l1x @benijo @RiKap @JanMikes
executable file 89 lines (63 sloc) 1.89 KB

Migrations

Content

Usage

At first you should register MigrationsExtension at your config file.

extensions:
    migrations: Nettrine\Migrations\DI\MigrationsExtension

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
extensions:
    console: Contributte\Console\DI\ConsoleExtension

Configuration

Default configuration looks like this:

migrations:
    table: doctrine_migrations 
    column: version
    directory: %appDir%/../migrations
    namespace: Migrations
    versionsOrganization: null # null, year, year_and_month
    customTemplate: null # path to custom template

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]

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;
/**
 * @var MyService
 */
private $myService;

public function injectMyService(MyService $myService): void
{
    $this->myService = $myService;
}

Read more at official Nette documentation.

You can’t perform that action at this time.