You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.7 KiB
51 lines
1.7 KiB
6 years ago
|
<?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 utf8 COLLATE utf8_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}}');
|
||
|
}
|
||
|
}
|