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