M221007083213AddQimallAddonsStoreOrderGive.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M221007083213AddQimallAddonsStoreOrderGive
  6. */
  7. class M221007083213AddQimallAddonsStoreOrderGive extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try{
  15. $table = 'qimall_addons_store_order_give';
  16. $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  17. $res = $this->db->createCommand($sql)->execute();
  18. if(!empty($res)) return '';
  19. $sql="CREATE TABLE `{$table}` (
  20. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  21. `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT 'mall_id',
  22. `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
  23. `order_id` int(11) NOT NULL DEFAULT '0' COMMENT '订单id',
  24. `give_score` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '赠送积分',
  25. `give_coupon` text COMMENT '赠送优惠券(json字符串保存)',
  26. `give_currency` text COMMENT '赠送货币(json字符串保存)',
  27. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  28. `created_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  29. `updated_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
  30. PRIMARY KEY (`id`) USING BTREE,
  31. KEY `order_id` (`order_id`) USING BTREE
  32. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='订单赠送表';
  33. ";
  34. $this->execute($sql);
  35. }catch (\Exception $e){}
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function safeDown()
  41. {
  42. echo "M221007083213AddQimallAddonsStoreOrderGive cannot be reverted.\n";
  43. return false;
  44. }
  45. /*
  46. // Use up()/down() to run migration code without a transaction.
  47. public function up()
  48. {
  49. }
  50. public function down()
  51. {
  52. echo "M221007083213AddQimallAddonsStoreOrderGive cannot be reverted.\n";
  53. return false;
  54. }
  55. */
  56. }