m200505_091520_add_localname   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 10 1
A safeDown() 0 3 1
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Class m200505_091520_add_localname
7
 */
8
class m200505_091520_add_localname extends Migration
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function safeUp()
14
    {
15
        $this->addColumn('language', 'native_name', $this->string(255)->after('name')->null()->comment('Language name in local'));
16
        $this->update('language', ['native_name' => new \yii\db\Expression('name')]);
17
        $this->alterColumn('language', 'native_name', $this->string(255)->notNull()->comment('Language name in local'));
18
        $this->update('language', ['native_name' => 'Eesti'], ['language_id' => 2]);
19
        $this->update('language', ['native_name' => 'Русский'], ['language_id' => 3]);
20
        $this->update('language', ['native_name' => 'Suomi'], ['language_id' => 4]);
21
        $this->update('language', ['native_name' => 'Latviešu'], ['language_id' => 5]);
22
        $this->update('language', ['native_name' => 'Lietuvių'], ['language_id' => 6]);
23
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function safeDown()
30
    {
31
        $this->dropColumn('language', 'native_name');
32
    }
33
}
34