@@ -2,13 +2,13 @@ PHPCR Migrations
22================
33
44[ ![ Build
5- Status] ( https://travis-ci.org/dantleech /phpcr-migrations.svg?branch=master )] ( https://travis-ci.org/dantleech /phpcr-migrations )
5+ Status] ( https://travis-ci.org/phpcr /phpcr-migrations.svg?branch=master )] ( https://travis-ci.org/phpcr /phpcr-migrations )
66
77Migrations library for PHPCR influenced by [ Doctrine
88migrations] ( https://github.com/doctrine/migrations ) .
99
1010For integration with Symfony see the [ PHPCR Migrations
11- Bundle] ( https://github.com/dantleech /phpcr-migrations-bundle ) .
11+ Bundle] ( https://github.com/phpcr /phpcr-migrations-bundle ) .
1212
1313Usage
1414-----
@@ -32,8 +32,43 @@ $output = new NullOutput();
3232$migrator->migrate($to, $output);
3333````
3434
35- Versions
36- --------
35+ You may also create a factory class (useful when you use dependency
36+ injection):
37+
38+ ````
39+ <?php
40+
41+ $factory = new MigratorFactory($storage, $finder, $session);
42+ $migrator = $factory->getMigrator();
43+ ````
44+
45+ ### Initializing
46+
47+ When you install a project for the first time you need to initialize the
48+ versions:
49+
50+ ````
51+ <?php
52+
53+ $migrator->initialize();
54+ ````
55+
56+ This should be part of your build process and it will add all the versions to
57+ the migration version node in the content repository.
58+
59+ ### Migrating
60+
61+
62+ ``` php
63+ $migrator->migrate('201501011200', $output); // migrate to a specific version
64+ $migrator->migrate('up', $output); // migrate up a version
65+ $migrator->migrate('down', $output); // migrate down a version
66+ $migrator->migrate('top', $output); // migrate to the latest version
67+ $migrator->migrate('bottom', $output); // revert all versions
68+ ````
69+
70+ Version classes
71+ ---------------
3772
3873Version classes contain `up` and `down` methods. The class is quite simple:
3974
@@ -58,3 +93,6 @@ class Version201504241200 implements VersionInterface
5893
5994They must be named `VersionYYYMMDDHHMM`. If they are not so named, then they
6095will not be detected.
96+
97+ The `down` method should revert any changes made in the `up` method. Always
98+ check that revcerting your migration works.
0 commit comments