m170727_081025_create_variant_to_shop_table.php
1.56 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
use yii\db\Migration;
/**
* Handles the creation of table `variant_to_shop`.
*/
class m170727_081025_create_variant_to_shop_table extends Migration
{
/**
* @inheritdoc
*/
public function up()
{
$this->createTable('variant_to_shop', [
'variant_id' => $this->integer()
->notNull(),
'shop_id' => $this->integer()
->notNull(),
'count' => $this->integer()->defaultValue(0),
]);
$this->addPrimaryKey(
'variant_to_shop_pk',
'variant_to_shop',
[
'variant_id',
'shop_id',
]
);
$this->addForeignKey(
'variant_to_shop_variant_id_to_variant_fk',
'variant_to_shop',
'variant_id',
'variant',
'id',
'CASCADE',
'CASCADE'
);
$this->addForeignKey(
'variant_to_shop_shop_id_to_shop_fk',
'variant_to_shop',
'shop_id',
'shop',
'id',
'CASCADE',
'CASCADE'
);
}
/**
* @inheritdoc
*/
public function down()
{
$this->dropForeignKey(
'variant_to_shop_variant_id_to_variant_fk',
'variant_to_shop'
);
$this->dropForeignKey(
'variant_to_shop_shop_id_to_shop_fk',
'variant_to_shop'
);
$this->dropTable('variant_to_shop');
}
}