|
|
|
<?php
|
|
|
|
|
|
|
|
use yii\db\Migration;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles the creation of table `settings_lng`.
|
|
|
|
*/
|
|
|
|
class m180910_182109_create_settings_lng_table extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function safeUp()
|
|
|
|
{
|
|
|
|
$tableOptions = null;
|
|
|
|
if ($this->db->driverName === 'mysql') {
|
|
|
|
$tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->createTable('{{%settings_lng}}', [
|
|
|
|
'id' => $this->primaryKey(),
|
|
|
|
'language' => $this->string(6)->notNull(),
|
|
|
|
'section' => $this->string(255)->notNull(),
|
|
|
|
'key' => $this->string(255)->notNull(),
|
|
|
|
'value' => $this->text(),
|
|
|
|
], $tableOptions);
|
|
|
|
|
|
|
|
$this->createIndex('key', '{{%settings_lng}}', ['section', 'key']);
|
|
|
|
$this->createIndex('idx_settings_lng_language', '{{%settings_lng}}', 'language');
|
|
|
|
$this->addForeignKey('frg_settings_lng_settings_setting_id_id', '{{%settings_lng}}', ['section', 'key'], '{{%settings}}', ['section', 'key'], 'CASCADE', 'CASCADE');
|
|
|
|
|
|
|
|
$this->dropColumn('{{%settings}}', 'id');
|
|
|
|
$this->addPrimaryKey('key', '{{%settings}}', ['section', 'key']);
|
|
|
|
$this->dropColumn('{{%settings}}', 'value');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function safeDown()
|
|
|
|
{
|
|
|
|
$this->addColumn('{{%settings}}', 'value', $this->text());
|
|
|
|
$this->dropPrimaryKey('key', '{{%settings}}');
|
|
|
|
$this->addColumn('{{%settings}}', 'id', $this->primaryKey());
|
|
|
|
|
|
|
|
$this->dropForeignKey('frg_settings_lng_settings_setting_id_id', '{{%settings_lng}}');
|
|
|
|
$this->dropIndex('idx_settings_lng_language', '{{%settings_lng}}');
|
|
|
|
$this->dropTable('{{%settings_lng}}');
|
|
|
|
}
|
|
|
|
}
|