M241231092053CreateUserOrderRelations.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M241231092053CreateUserOrderRelations
  6. */
  7. class M241231092053CreateUserOrderRelations extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $sql = <<<SQL
  15. CREATE TABLE `qimall_user_order_relations` (
  16. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  17. `mall_id` int(10) unsigned NOT NULL DEFAULT '0',
  18. `order_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '订单id',
  19. `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  20. `parents` json NOT NULL COMMENT '下单时的上级关系链,包含等级',
  21. `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态 -1删除 0禁用 1正常',
  22. `created_at` int(10) unsigned NOT NULL DEFAULT '0',
  23. `updated_at` int(10) unsigned NOT NULL DEFAULT '0',
  24. PRIMARY KEY (`id`),
  25. KEY `order_id` (`order_id`)
  26. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='记录订单支付时,下单人关系链的等级';
  27. SQL;
  28. $this->execute($sql);
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function safeDown()
  34. {
  35. return false;
  36. }
  37. /*
  38. // Use up()/down() to run migration code without a transaction.
  39. public function up()
  40. {
  41. }
  42. public function down()
  43. {
  44. echo "M241231092053CreateUserOrderRelations cannot be reverted.\n";
  45. return false;
  46. }
  47. */
  48. }