Browse Source

Init languages on migration

master
Egorka 6 years ago
parent
commit
c1c1d68f46
  1. 33
      common/modules/languages/migrations/m180905_063026_init_first_languages.php

33
common/modules/languages/migrations/m180905_063026_init_first_languages.php

@ -0,0 +1,33 @@
<?php
use yii\db\Migration;
use common\modules\languages\entities\Language;
/**
* Class m180905_063026_init_first_languages
*/
class m180905_063026_init_first_languages extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$languages = Language::find()->all();
if (!$languages) {
$this->batchInsert('{{%languages}}', ['name', 'title', 'status', 'default'], [
['ru', 'Русский', Language::STATUS_ACTIVE, Language::DEFAULT_TRUE],
['en', 'English', Language::STATUS_ACTIVE, Language::DEFAULT_FALSE],
]);
}
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->delete('{{%languages}}', ['in', 'name', ['ru', 'en']]);
}
}
Loading…
Cancel
Save