| Total Complexity | 2 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class AddPermissionsTable20210717094547 extends AbstractMigration |
||
| 9 | {
|
||
| 10 | public function up(): void |
||
| 11 | {
|
||
| 12 | //Action when migrate up |
||
| 13 | $this->create('permissions', function (CreateTable $table) {
|
||
| 14 | $table->integer('id')
|
||
| 15 | ->autoincrement() |
||
| 16 | ->primary(); |
||
| 17 | |||
| 18 | $table->string('code')
|
||
| 19 | ->description('The permission code')
|
||
| 20 | ->unique() |
||
| 21 | ->notNull(); |
||
| 22 | |||
| 23 | $table->string('description')
|
||
| 24 | ->description('The permission description')
|
||
| 25 | ->notNull(); |
||
| 26 | |||
| 27 | $table->integer('parent_id')
|
||
| 28 | ->description('The parent permission');
|
||
| 29 | |||
| 30 | $table->timestamps(); |
||
| 31 | |||
| 32 | $table->foreign('parent_id')
|
||
| 33 | ->references('permissions', 'id')
|
||
| 34 | ->onDelete('CASCADE');
|
||
| 35 | |||
| 36 | $table->engine('INNODB');
|
||
| 37 | }); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function down(): void |
||
| 44 | } |
||
| 45 | } |
||
| 46 |