From 1a8cf1e8f9431147ce0f9d813346f4bc803b521c Mon Sep 17 00:00:00 2001 From: Anton Shevchuk Date: Thu, 12 Oct 2017 19:22:23 +0300 Subject: [PATCH] Fixed migrations (divided into structure and data migrations) --- README.md | 1 + ...p => 20170317111411_module_categories.php} | 12 ------ ...17111412_module_categories_permissions.php | 39 +++++++++++++++++++ 3 files changed, 40 insertions(+), 12 deletions(-) rename data/migrations/{20170317111114_module_categories.php => 20170317111411_module_categories.php} (84%) create mode 100644 data/migrations/20170317111412_module_categories_permissions.php diff --git a/README.md b/README.md index 5ec0697..160f3ee 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ To install the module run the command: ```bash php /vendor/bin/bluzman module:install categories +php /vendor/bin/bluzman db:migrate ``` ### Remove module diff --git a/data/migrations/20170317111114_module_categories.php b/data/migrations/20170317111411_module_categories.php similarity index 84% rename from data/migrations/20170317111114_module_categories.php rename to data/migrations/20170317111411_module_categories.php index 54dc150..6e16423 100644 --- a/data/migrations/20170317111114_module_categories.php +++ b/data/migrations/20170317111411_module_categories.php @@ -47,17 +47,5 @@ public function change() ]) ->addIndex(['parentId', 'alias'], ['unique' => true, 'name' => 'UNIQUE_categories_alias']) ->create(); - - $data = [ - [ - 'roleId' => 2, - 'module' => 'categories', - 'privilege' => 'Management' - ] - ]; - - $privileges = $this->table('acl_privileges'); - $privileges->insert($data) - ->save(); } } diff --git a/data/migrations/20170317111412_module_categories_permissions.php b/data/migrations/20170317111412_module_categories_permissions.php new file mode 100644 index 0000000..1972087 --- /dev/null +++ b/data/migrations/20170317111412_module_categories_permissions.php @@ -0,0 +1,39 @@ + 2, + 'module' => 'categories', + 'privilege' => 'Management' + ] + ]; + + $privileges = $this->table('acl_privileges'); + $privileges->insert($data) + ->save(); + } + + /** + * Migrate Down. + */ + public function down() + { + $this->execute('DELETE FROM acl_privileges WHERE module = "categories"'); + } +}