m220412_144550_create_product_table.php
929 Bytes
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
<?php
use yii\db\Migration;
/**
* Handles the creation of table `product`.
*/
class m220412_144550_create_product_table extends Migration
{
/**
* @inheritdoc
*/
public function up()
{
$this->createTable('product', [
'id' => $this->primaryKey(),
'status' => $this->boolean(),
'sort' => $this->smallInteger(),
'sku' =>$this->string(255),
'image_id' => $this->integer(),
]);
$this->addForeignKey(
'fk-product-image_id',
'product',
'image_id',
'ImageManager',
'id',
'CASCADE'
);
}
/**
* @inheritdoc
*/
public function down()
{
$this->dropForeignKey(
'fk-product-image_id',
'product'
);
$this->dropTable('product');
}
}