M230606010207QimallAddonsCloudStockFillOrderRelation.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace addons\CloudStock\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230606010207QimallAddonsCloudStockFillOrderRelation
  6. */
  7. class M230606010207QimallAddonsCloudStockFillOrderRelation extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_addons_cloud_stock_fill_order_relation';
  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 `qimall_addons_cloud_stock_fill_order_relation` (
  20. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  21. `mall_id` int(11) NOT NULL COMMENT '商城id',
  22. `user_id` int(11) NOT NULL COMMENT '补货代理商用户id',
  23. `order_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '订单id',
  24. `fill_order_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '补货订单id',
  25. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  26. `created_at` int(11) NOT NULL DEFAULT '0',
  27. `updated_at` int(11) NOT NULL DEFAULT '0',
  28. PRIMARY KEY (`id`) USING BTREE
  29. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='购买升级礼包,订单-补货订单关联表';";
  30. $this->execute($sql);
  31. }catch (\Exception $e){
  32. }
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function safeDown()
  38. {
  39. echo "M230606010207QimallAddonsCloudStockFillOrderRelation cannot be reverted.\n";
  40. return false;
  41. }
  42. /*
  43. // Use up()/down() to run migration code without a transaction.
  44. public function up()
  45. {
  46. }
  47. public function down()
  48. {
  49. echo "M230606010207QimallAddonsCloudStockFillOrderRelation cannot be reverted.\n";
  50. return false;
  51. }
  52. */
  53. }