| Total Complexity | 3 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class m010101_100001_init_comment extends Migration |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Create table `Comment` |
||
| 12 | */ |
||
| 13 | public function up() |
||
| 14 | { |
||
| 15 | $tableOptions = null; |
||
| 16 | |||
| 17 | if ('mysql' === $this->db->driverName) { |
||
| 18 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
||
| 19 | } |
||
| 20 | |||
| 21 | $this->createTable('{{%Comment}}', [ |
||
| 22 | 'id' => $this->primaryKey(), |
||
| 23 | 'entity' => $this->char(10)->notNull(), |
||
| 24 | 'entityId' => $this->integer()->notNull(), |
||
| 25 | 'content' => $this->text()->notNull(), |
||
| 26 | 'parentId' => $this->integer()->null(), |
||
| 27 | 'level' => $this->smallInteger()->notNull()->defaultValue(1), |
||
| 28 | 'createdBy' => $this->integer()->notNull(), |
||
| 29 | 'updatedBy' => $this->integer()->notNull(), |
||
| 30 | 'status' => $this->smallInteger()->notNull()->defaultValue(1), |
||
| 31 | 'createdAt' => $this->integer()->notNull(), |
||
| 32 | 'updatedAt' => $this->integer()->notNull(), |
||
| 33 | ], $tableOptions); |
||
| 34 | |||
| 35 | $this->createIndex('idx-Comment-entity', '{{%Comment}}', 'entity'); |
||
| 36 | $this->createIndex('idx-Comment-status', '{{%Comment}}', 'status'); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Drop table `Comment` |
||
| 41 | */ |
||
| 42 | public function down() |
||
| 45 | } |
||
| 46 | } |
||
| 47 |