M180121204747Init::safeUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 18
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace console\migrations;
3
4
use yii\db\Migration;
5
6
class M180121204747Init extends Migration
7
{
8
    const TABLE_OPTION = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
9
10
    /**
11
     * @inheritdoc
12
     */
13
    public function safeUp()
14
    {
15
        $this->createTable('{{%mailer_domains}}', [
16
            'id' => $this->primaryKey(),
17
            'name' => $this->string(50)->notNull(),
18
        ], self::TABLE_OPTION);
19
        $this->createTable('{{%mailer_users}}', [
20
            'id' => $this->primaryKey(),
21
            'domain_id' => $this->integer()->notNull(),
22
            'email' => $this->string(120)->unique()->notNull(),
23
            'password' => $this->string(106)->notNull(),
24
        ], self::TABLE_OPTION);
25
        $this->createTable('{{%mailer_aliases}}', [
26
            'id' => $this->primaryKey(),
27
            'domain_id' => $this->integer()->notNull(),
28
            'source' => $this->string(100)->notNull(),
29
            'destination' => $this->string(100)->notNull(),
30
        ], self::TABLE_OPTION);
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36
    public function safeDown()
37
    {
38
        $this->dropTable('{{%mailer_domains}}');
39
        $this->dropTable('{{%mailer_users}}');
40
        $this->dropTable('{{%mailer_aliases}}');
41
    }
42
}
43