This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Update README.md

  • Loading branch information...
1 parent f6b0b1c commit e5eaffd546990f162cdc8fbdb186317827529a3d @kbond committed Apr 19, 2012
Showing with 103 additions and 0 deletions.
  1. +103 −0 README.md
View
103 README.md
@@ -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.