m160204_103008_add_payment_connections.php
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
use yii\db\Migration;
class m160204_103008_add_payment_connections extends Migration
{
public function up ()
{
$this->createTable (
'{{%payment}}', [
'payment_id' => $this->primaryKey (), 'name' => $this->string (255)
->notNull (), 'status' => $this->integer ()
->defaultValue (1),
], null
);
$this->batchInsert ('{{%payment}}', ['name'], [['Наличный расчет'], ['Безналичный расчет'], ['Электронные деньги']]);
$this->createTable (
'{{%user_payment}}', [
'user_payment_id' => $this->primaryKey (), 'user_id' => $this->integer (), 'payment_id' => $this->integer (),
]
);
$this->createTable (
'{{%user_specialization}}', [
'user_specialization_id' => $this->primaryKey (), 'user_id' => $this->integer (), 'specialization_id' => $this->integer (),
]
);
$this->addForeignKey ('user_speialization_specialization', '{{%user_specialization}}', 'specialization_id', '{{%specialization}}', 'specialization_id', 'CASCADE', 'CASCADE');
$this->addForeignKey ('user_payment_payment', '{{%user_payment}}', 'payment_id', '{{%payment}}', 'payment_id', 'CASCADE', 'CASCADE');
}
public function down ()
{
$this->dropTable ('{{%payment}}');
$this->dropTable('{{%user_specialization}}');
$this->dropTable('{{%user_payment}}');
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}