Implementation of Doctrine\Migrations to Nette.
Tip: Symfony bundle is more clear to read.
The best way to install is using Composer.
Add to your composer.json
:
"require": {
"doctrine/migrations": "@dev"
"zenify/doctrine-migrations": "@dev"
}
and run:
$ composer update
Register the extension in config.neon
:
extensions:
migrations: Zenify\DoctrineMigrations\DI\MigrationsExtension
config.neon with default values
migrations:
table: doctrine_migrations # database table for applied migrations
dirs: # list of dirs to load migrations from
- %appDir%/../migrations # first dir is used for generating migrations
namespace: Migrations # namespace of migration classes
enabled: FALSE # cli based loading; set TRUE to force loading in non-cli
namespace Migrations;
class Version20140801152432 extends AbstractMigration
{
/**
* @inject
* @var \Kdyby\Doctrine\EntityManager
*/
public $em;
public function up(Schema $schema)
{
$product = new Product;
$product->setName('Chips without fish')
$this->em->persist(product);
$this->em->flush();
}
// ...
}