Completed
Push — master ( d1140b...3de4fa )
by Viacheslav
01:39
created

m200725_141600_create_job_progress_table::up()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 10
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 16
ccs 0
cts 13
cp 0
crap 6
rs 9.9332
1
<?php
2
3
namespace slavkluev\JobProgress\migrations;
4
5
use yii\db\Migration;
6
7
class m200725_141600_create_job_progress_table extends Migration
8
{
9
    public $tableName = '{{%job_progress}}';
10
11
    public function up()
12
    {
13
        $tableOptions = null;
14
        if ($this->db->driverName === 'mysql') {
15
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
16
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
17
        }
18
19
        $this->createTable($this->tableName, [
20
            'id' => $this->primaryKey(),
21
            'job_id' => $this->integer()->notNull(),
22
            'progress_max' => $this->integer()->notNull(),
23
            'progress_now' => $this->integer()->notNull(),
24
        ], $tableOptions);
25
26
        $this->createIndex('job_id', $this->tableName, 'job_id');
27
    }
28
29
    public function down()
30
    {
31
        $this->dropTable($this->tableName);
32
    }
33
}
34