Skip to content

Commit a249654

Browse files
Anton ShevchukAnton Shevchuk
authored andcommitted
Fixed migrations (divided into structure and data migrations)
1 parent 5dddb0b commit a249654

File tree

3 files changed

+55
-27
lines changed

3 files changed

+55
-27
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ To install the module run the command:
1919

2020
```bash
2121
php /vendor/bin/bluzman module:install test
22+
php /vendor/bin/bluzman db:migrate
2223
```
2324

2425
### Remove module

data/migrations/20170317111111_module_test.php renamed to data/migrations/20170317111211_module_test.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,5 @@ public function change()
4242
->addColumn('status', 'enum', ['values' => ['active', 'disable', 'delete']])
4343
->addTimestamps('created', 'updated')
4444
->create();
45-
46-
$data = [
47-
[
48-
'roleId' => 2,
49-
'module' => 'test',
50-
'privilege' => 'Create'
51-
],
52-
[
53-
'roleId' => 2,
54-
'module' => 'test',
55-
'privilege' => 'Read'
56-
],
57-
[
58-
'roleId' => 2,
59-
'module' => 'test',
60-
'privilege' => 'Update'
61-
],
62-
[
63-
'roleId' => 2,
64-
'module' => 'test',
65-
'privilege' => 'Delete'
66-
],
67-
];
68-
69-
$privileges = $this->table('acl_privileges');
70-
$privileges->insert($data)
71-
->save();
7245
}
7346
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* @copyright Bluz PHP Team
4+
* @link https://github.com/bluzphp/skeleton
5+
*/
6+
7+
use Phinx\Migration\AbstractMigration;
8+
9+
/**
10+
* CreateTestTable
11+
*/
12+
class ModuleTestPermissions extends AbstractMigration
13+
{
14+
/**
15+
* Migrate Up.
16+
*/
17+
public function up()
18+
{
19+
$data = [
20+
[
21+
'roleId' => 2,
22+
'module' => 'test',
23+
'privilege' => 'Create'
24+
],
25+
[
26+
'roleId' => 2,
27+
'module' => 'test',
28+
'privilege' => 'Read'
29+
],
30+
[
31+
'roleId' => 2,
32+
'module' => 'test',
33+
'privilege' => 'Update'
34+
],
35+
[
36+
'roleId' => 2,
37+
'module' => 'test',
38+
'privilege' => 'Delete'
39+
],
40+
];
41+
42+
$privileges = $this->table('acl_privileges');
43+
$privileges->insert($data)
44+
->save();
45+
}
46+
47+
/**
48+
* Migrate Down.
49+
*/
50+
public function down()
51+
{
52+
$this->execute('DELETE FROM acl_privileges WHERE module = "test"');
53+
}
54+
}

0 commit comments

Comments
 (0)