| Total Complexity | 5 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class m160426_220525_settings extends Migration |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var string |
||
| 9 | */ |
||
| 10 | public $tableName = '{{%settings}}'; |
||
| 11 | |||
| 12 | public function up() |
||
| 13 | { |
||
| 14 | $tableOptions = null; |
||
| 15 | if ($this->db->driverName === 'mysql') { |
||
| 16 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
||
| 17 | } |
||
| 18 | |||
| 19 | $this->createTable($this->tableName, [ |
||
| 20 | // 32 (key length) + 32 (keyPrefix length) |
||
| 21 | 'id' => $this->string(64)->notNull() . |
||
| 22 | ($this->db->driverName === 'sqlite' ? ' PRIMARY KEY' : ''), |
||
| 23 | |||
| 24 | // Caching a query to the db with BLOB data type |
||
| 25 | // https://github.com/yiisoft/yii2/issues/9899 |
||
| 26 | 'data' => $this->text(), |
||
| 27 | ], $tableOptions); |
||
| 28 | |||
| 29 | if ($this->db->driverName !== 'sqlite') { |
||
| 30 | $this->addPrimaryKey('settings_pk', $this->tableName, 'id'); |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | public function down() |
||
| 35 | { |
||
| 36 | $this->dropTable($this->tableName); |
||
| 37 | } |
||
| 39 |