m170302_104953_create_rejections   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 18
c 1
b 0
f 0
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 16 2
A safeDown() 0 6 1
1
<?php
2
3
use yii\db\Migration;
4
5
class m170302_104953_create_rejections extends Migration
6
{
7
    private $tableName ='rejection';
8
9
10
    public function safeUp()
11
    {
12
        if (!in_array($this->tableName, $this->getDb()->schema->tableNames)) {
13
            $this->createTable($this->tableName, [
14
                'rejection_id' => $this->primaryKey()->comment('ID'),
15
                'survey_id' => $this->integer()->comment('Survey'),
16
                'respondent_id' => $this->integer()->comment('Respondent'),
17
                'email_address' => $this->string(255)->notNull()->comment('email address to send email to'),
18
                'response_code' => $this->integer(4)->comment('Email response code in case of bounce'),
19
                'type' => $this->string(45)->comment('Bounce type'),
20
                'bounce' => $this->text()->comment('Sisimai bounce object as JSON'),
21
                'time_rejected' => $this->dateTime()->notNull()->comment('Rejection time'),
22
            ]);
23
24
            $this->addForeignKey('fk_rejection_survey_id',$this->tableName,'survey_id','survey','survey_id');
25
            $this->addForeignKey('fk_rejection_respondent_id','rejection','respondent_id','respondent','respondent_id');
26
        }
27
28
    }
29
30
    public function safeDown()
31
    {
32
        $this->dropForeignKey('fk_rejection_survey_id',$this->tableName);
33
        $this->dropForeignKey('fk_rejection_email_id',$this->tableName);
34
        $this->dropForeignKey('fk_rejection_respondent_id',$this->tableName);
35
        $this->dropTable($this->tableName);
36
    }
37
}
38