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
|
|
|
|