Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Apr 19, 2012
1 parent f6b0b1c commit e5eaffd
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# ZenstruckMigrationsBundle

Wrapper for DoctrineMigrationsBundle that enables container aware migrations.

## Installation

1. Add this bundle to your project
* Using `deps` file

```ini
[ZenstruckMigrationsBundle]
git=git://github.com/kbond/ZenstruckMigrationsBundle.git
target=bundles/Zenstruck/Bundle/MigrationsBundle
```
* Using submodules

```
git submodule add git://github.com/kbond/ZenstruckMigrationsBundle.git vendor/bundles/Zenstruck/Bundle/MigrationsBundle
```

2. Register the namespaces

```php
<?php
// app/autoload.php
$loader->registerNamespaces(array(
// ...
'Zenstruck' => __DIR__.'/../vendor/bundles',
// ...
));
```

3. Register the bundle

```php
<?php
// app/AppKernel.php

public function registerBundles()
{
$bundles = array(
// ...
new Zenstruck\Bundle\MigrationsBundle\ZenstruckMigrationsBundle(),
);
// ...
)
```

## Usage

* To make use of container aware data migrations your migrations must extend
`Zenstruck\Bundle\MigrationsBundle\Migrations\AbstractMigration`. (**note:** Migrations that extend
`Doctrine\DBAL\Migrations\AbstractMigration` will still run normally)
* Implement the `dataUp()` method and add your custom migration logic. (**note:** The `up()` method will be run
before `dataUp`)
* _Optionally_ implement the `getDataDescription` method and return a description of the migration.
* Migrate using the `zenstruck:migrations:migrate` command.
(**note:** make sure you run migrations with this command and not `doctrine:migrations:migrate`

## Migration Template

```php
<?php

namespace Application\Migrations;

use Zenstruck\Bundle\MigrationsBundle\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Auto-generated Migration: Please modify to your need!
*/
class Version20120419113825 extends AbstractMigration
{
public function up(Schema $schema)
{
// this up() migration is autogenerated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");

}

public function down(Schema $schema)
{
// this down() migration is autogenerated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");

}

public function dataUp(ContainerInterface $container)
{
// container aware logic
}

/**
* OPTIONAL
*/
public function getDataDescription()
{
return parent::getDataDescription();
}
}
```

0 comments on commit e5eaffd

Please sign in to comment.