portal.mkgtu.ru/common/migrations/db/m160318_065935_add_settings...

34 lines
946 B
PHP
Raw Permalink Normal View History

2024-03-28 09:51:45 +03:00
<?php
use common\components\Migration\MigrationWithDefaultOptions;
class m160318_065935_add_settings_table extends MigrationWithDefaultOptions
{
public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%sandbox_settings}}', [
'id' => $this->primaryKey(),
'name' => $this->string(100)->notNull(),
'value' => $this->string(1000)->notNull(),
], $tableOptions);
$this->insert('{{%sandbox_settings}}', [
'name' => 'sandbox_enabled',
'value' => '1',
]);
Yii::$app->db->schema->refresh();
}
public function safeDown()
{
$this->dropTable('{{%sandbox_settings}}');
Yii::$app->db->schema->refresh();
}
}