m181111_134257_create_order_table.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. use yii\db\Migration;
  3. use yii\db\Schema;
  4. /**
  5. * Handles the creation of table `{{%order}}`.
  6. */
  7. class m181111_134257_create_order_table extends Migration
  8. {
  9. public $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
  10. /**
  11. * @inheritdoc
  12. */
  13. public function up()
  14. {
  15. $this->createTable('{{%order}}', [
  16. 'id' => Schema::TYPE_PK,
  17. 'user_id' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '用户ID'",
  18. 'out_trade_no' => Schema::TYPE_STRING . "(32) NOT NULL COMMENT '商户订单号'",
  19. 'order_no' => Schema::TYPE_STRING . "(16) NOT NULL COMMENT '订单号'",
  20. 'total_amount' => Schema::TYPE_DECIMAL . "(10,2) NOT NULL COMMENT '订单总金额'",
  21. 'pay_amount' => Schema::TYPE_DECIMAL . "(10,2) NOT NULL COMMENT '实付金额'",
  22. 'pay_time' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '支付时间'",
  23. 'remark' => Schema::TYPE_STRING . "(100) NOT NULL COMMENT '备注'",
  24. 'receiver_name' => Schema::TYPE_STRING . "(20) NOT NULL COMMENT '收件人姓名'",
  25. 'receiver_tel' => Schema::TYPE_STRING . "(11) NOT NULL COMMENT '收件人电话'",
  26. 'receiver_address' => Schema::TYPE_STRING . "(200) NOT NULL COMMENT '收件人地址'",
  27. 'created_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
  28. 'updated_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
  29. 'status' => Schema::TYPE_SMALLINT . "(1) NOT NULL DEFAULT '1' COMMENT '状态'",
  30. 'detail' => Schema::TYPE_STRING . "(300) COMMENT '订单详情'",
  31. ]);
  32. }
  33. /**
  34. * @inheritdoc
  35. */
  36. public function down()
  37. {
  38. $this->dropTable('{{%order}}');
  39. }
  40. }