Completed
Branch master (4042af)
by Aleksandar
02:32
created

Menu   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 7
1
<?php
2
3
use Phinx\Migration\AbstractMigration;
4
5
class Menu extends AbstractMigration
6
{
7
    public function up()
8
    {
9
        $this->table('menu', ['id' => false, 'primary_key' => 'menu_uuid'])
10
            ->addColumn('menu_uuid', 'binary', ['limit' => 16])
11
            ->addColumn('menu_id', 'text')
12
            ->addColumn('parent_id', 'text', ['null' => true])
13
            ->addColumn('title', 'text')
14
            ->addColumn('href', 'text', ['null' => true])
15
            ->addColumn('is_active', 'boolean', ['default' => false])
16
            ->addColumn('is_in_header', 'boolean', ['default' => true])
17
            ->addColumn('is_in_footer', 'boolean', ['default' => true])
18
            ->addColumn('is_in_side', 'boolean', ['default' => true])
19
            ->addColumn('order_no', 'integer', ['default' => 0])
20
            ->addColumn('created_at', 'datetime', ['null' => true])
21
            //->addForeignKey('parent_id', 'menu', 'id', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) # we can not add constraints
22
            ->addColumn('page_uuid', 'binary', ['limit' => 16, 'null' => true])
23
            ->addColumn('category_uuid', 'binary', ['limit' => 16, 'null' => true])
24
            ->addForeignKey('page_uuid', 'page', 'page_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION'])
25
            ->addForeignKey('category_uuid', 'category', 'category_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION'])
26
            ->create();
27
    }
28
29
    public function down()
30
    {
31
        $this->dropTable('menu');
32
    }
33
}
34