Conditions | 3 |
Paths | 4 |
Total Lines | 25 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 19 |
CRAP Score | 3 |
1 | <?php |
||
18 | 219 | public function up() |
|
19 | { |
||
20 | 219 | ob_start(); |
|
21 | 219 | $tableOptions = null; |
|
22 | 219 | if ($this->db->driverName === 'mysql') { |
|
23 | // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci |
||
24 | 73 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
|
25 | 73 | } |
|
26 | |||
27 | // tree |
||
28 | 219 | if ($this->db->getTableSchema('{{%tree}}', true) !== null) { |
|
29 | 215 | $this->dropTable('{{%tree}}'); |
|
30 | 215 | } |
|
31 | 219 | $this->createTable('{{%tree}}', [ |
|
32 | 219 | 'id' => Schema::TYPE_PK, |
|
33 | 219 | 'parent_id' => Schema::TYPE_INTEGER . ' NULL', |
|
34 | 219 | 'sort' => Schema::TYPE_INTEGER . ' NOT NULL', |
|
35 | 219 | 'slug' => Schema::TYPE_STRING . ' NOT NULL', |
|
36 | 219 | ], $tableOptions); |
|
37 | 219 | $this->createIndex('parent_sort', '{{%tree}}', ['parent_id', 'sort']); |
|
38 | |||
39 | // update cache (sqlite bug) |
||
40 | 219 | $this->db->getSchema()->getTableSchema('{{%tree}}', true); |
|
41 | 219 | ob_end_clean(); |
|
42 | 219 | } |
|
43 | } |
||
44 |