Completed
Push — master ( 36c150...f901ae )
by Razon
02:34
created

m190822_070404_data_article   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 20
c 1
b 0
f 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 19 1
A safeDown() 0 4 1
1
<?php
2
use App\Db\Migration;
3
4
/**
5
 * Class m190822_070404_data_article
6
 */
7
class m190822_070404_data_article extends Migration
8
{
9
    private $tableName = '{{%article}}';
10
11
    private $metaTableName = '{{%article_meta}}';
12
13
    public function safeUp()
14
    {
15
        $now = time();
16
        $this->insert($this->tableName, [
17
            'id' => 1,
18
            'title' => 'Hello World',
19
            'creator' => 1,
20
            'author' => 'Administrator',
21
            'category_id' => 1,
22
            'summary' => 'Congratulation! You have set up Yii2 and Vue application.', 
23
            'cover' => '',
24
            'release_time' => $now,
25
            'create_time' => $now, 
26
            'update_time' => $now,
27
        ]);
28
29
        $this->insert($this->metaTableName, [
30
            'article_id' => 1,
31
            'content' => '<h1>Congratulation!</h1><p>You have set up Yii2 and Vue application.</p>',
32
        ]);
33
    }
34
35
    public function safeDown()
36
    {
37
        $this->truncateTable($this->tableName);
38
        $this->truncateTable($this->metaTableName);
39
    }
40
}
41