-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm170208_094405_create_menuitem_table.php
45 lines (40 loc) · 1.5 KB
/
m170208_094405_create_menuitem_table.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* This file is part of the mgrechanik/yii2-materialized-path library
*
* @copyright Copyright (c) Mikhail Grechanik <[email protected]>
* @license https://github.com/mgrechanik/yii2-materialized-path/blob/master/LICENCE.md
* @link https://github.com/mgrechanik/yii2-materialized-path
*/
use yii\db\Migration;
/**
* Handles the creation of table `menuitem`.
*/
class m170208_094405_create_menuitem_table extends Migration
{
/**
* @inheritdoc
*/
public function up()
{
$this->createTable('menuitem', [
'id' => $this->primaryKey(),
'treeid' => $this->integer(4)->notNull()->comment('The id of the menu this menuitem belongs to'),
'path' => $this->string(255)->notNull()->defaultValue('')->comment('Path to parent node'),
'level' => $this->integer(4)->notNull()->defaultValue(1)->comment('Level of the node in the tree'),
'weight' => $this->integer(11)->notNull()->defaultValue(1)->comment('Weight among siblings'),
'name' => $this->string()->notNull()->comment('Name'),
]);
$this->createIndex('menuitem_path_index', 'menuitem', 'path');
$this->createIndex('menuitem_level_index', 'menuitem', 'level');
$this->createIndex('menuitem_weight_index', 'menuitem', 'weight');
$this->createIndex('menuitem_treeid_index', 'menuitem', 'treeid');
}
/**
* @inheritdoc
*/
public function down()
{
$this->dropTable('menuitem');
}
}