Completed
Push — master ( 8e2e58...8b4476 )
by zacksleo
03:01
created

m170903_131715_create_order_table::up()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
cc 2
eloc 21
nc 2
nop 0
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `order`.
7
 */
8
class m170903_131715_create_order_table extends Migration
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    public function up()
14
    {
15
        $tableOptions = null;
16
        if ($this->db->driverName === 'mysql') {
17
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
18
        }
19
        $this->createTable('{{%order}}', [
20
            'id' => $this->primaryKey(),
21
            'name' => $this->string()->notNull()->comment('名称'),
22
            'user_id' => $this->integer()->notNull()->comment('用户'),
23
            'recipient' => $this->string()->comment('收件人'),
24
            'phone' => $this->string()->comment('电话'),
25
            'payment_method' => $this->smallInteger()->comment('支付方式'),
26
            'total_amount' => $this->decimal(10, 2)->comment('总金额'),
27
            'status' => $this->smallInteger()->comment('状态'),
28
            'sn' => $this->string()->comment('订单编号'),
29
            'created_at' => $this->integer()->comment('创建时间'),
30
            'updated_at' => $this->integer()->comment('更新时间'),
31
            'address' => $this->string()->comment('配送地址'),
32
            'express' => $this->string()->comment('快递公司'),
33
            'tracking_no' => $this->string()->comment('物流编号'),
34
            'remark' => $this->string()->comment('备注'),
35
        ], $tableOptions);
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function down()
42
    {
43
        $this->dropTable('{{%order}}');
44
    }
45
}
46