From 5817b6f6b4c2942eb20f53668ea6b8894c8b6833 Mon Sep 17 00:00:00 2001 From: Paul Clegg Date: Tue, 22 Nov 2016 08:51:46 +0000 Subject: [PATCH] updated docs --- README.md | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/README.md b/README.md index 2d3caa8..65909de 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,91 @@ This plugin provides a simple mechanism for implementing version controllable da in a lightweight convention similar to packages such as Phinx or Doctrine Migrations. ## Installation +Install using composer: + +``` +composer require gatherdigitaluk/pimcore-migrations +``` ## Configuration +Configuration is intended to be as simple as possible. +1. After install ensure that the extensionis listed as follows in your extensions.php file +```php + TRUE + ]; +?> +``` +2. Migrations should be placed in your /website/var/plugins/PimcoreMigrations/migrations folder. + +3. The plugin will automatically install a new table into the pimcore environment upon detecting a migrations folder when the console app is executed. + ## Usage +### Extend the AbstractMigration Class + +1. Each migration should extend the class PimcoreMigrations\Model\AbstractMigration. +2. It can be named however you wish, although the last part of the name should be a numeric value separated by an underscore (_). +For example: + - some_table_changes_1000.php + - new_custom_persistent_class_1001.php + - anotherdifferentlynamedclass_1002.php +3. Each migration class should have a similarly named classname following the same pattern as Pimcore, example: + - SomeTableChanges1000 + - NewCustomPersistentClass1001 + - Anotherdifferentlynamedclass1002 +4. If we created the classes above we would have the following versions (represented by an integer) + - 1000 + - 1001 + - 1002 + +### Implement the required class methods +Each Migration should contain both an up() and down() method. UP being the default operation, and DOWN being to roll +back changes. Here is an example: + +```php +query("CREATE table `test`"); + } + + public function down() + { + \Pimcore\Db::get()->query("DROP table `test`"); + } + +} + + +``` + +### Run the console app +Migrations can be run through the console application made available in the Pimcore\Cli. Running as a plugin ensures that +all migrations are runnning in the Pimcore environment. There are 3 commands available and can be run as follows: + +1. Check Status +``` +php console.php deployment:migrations:status +``` + +2. Migrate up +``` +php console.php deployment:migrations:up +or +php console.php deployment:migrations:up --fromVersion 1000 --toVersion 1001 +``` + +3. Migrate down +``` +php console.php deployment:migrations:down +or +php console.php deployment:migrations:down --fromVersion 1000 --toVersion 1001 +``` +