@@ -2,13 +2,13 @@ PHPCR Migrations
2
2
================
3
3
4
4
[ ![ 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 )
6
6
7
7
Migrations library for PHPCR influenced by [ Doctrine
8
8
migrations] ( https://github.com/doctrine/migrations ) .
9
9
10
10
For 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 ) .
12
12
13
13
Usage
14
14
-----
@@ -32,8 +32,43 @@ $output = new NullOutput();
32
32
$migrator->migrate($to, $output);
33
33
````
34
34
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
+ ---------------
37
72
38
73
Version classes contain `up` and `down` methods. The class is quite simple:
39
74
@@ -58,3 +93,6 @@ class Version201504241200 implements VersionInterface
58
93
59
94
They must be named `VersionYYYMMDDHHMM`. If they are not so named, then they
60
95
will 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