M221124013130InsertQimallCrontabTask.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace addons\HiGo\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M221124013130InsertQimallCrontabTask
  6. */
  7. class M221124013130InsertQimallCrontabTask extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. // $table = 'qimall_crontab_task';
  16. // $check_table_sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  17. // $res = $this->db->createCommand($check_table_sql)->execute();
  18. // if(!empty($res)) return '';
  19. //查询数据是否存在
  20. $sql = "select * from qimall_crontab_task where command = 'hi-go/merchant-crontab/order-finish-mode' or command = 'hi-go/merchant-crontab/order-to-mode'";
  21. $res = $this->db->createCommand($sql)->execute();
  22. if($res) return '';
  23. // 插入表数据
  24. $sql = "INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ( '嗨购-打赏完成后订单模式结束处理', 'hi-go/merchant-crontab/order-finish-mode', 2, '0 */5 * * * *', 0, 1, 1669253273, 1669253273);";
  25. $this->execute($sql);
  26. $sql = "INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ( '嗨购-打赏完成后订单模式开始处理', 'hi-go/merchant-crontab/order-to-mode', 2, '0 */5 * * * *', 0, 1, 1669253273, 1669253273);";
  27. $this->execute($sql);
  28. }catch (\Exception $e){
  29. }
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function safeDown()
  35. {
  36. echo "M221124013130InsertQimallCrontabTask cannot be reverted.\n";
  37. return false;
  38. }
  39. /*
  40. // Use up()/down() to run migration code without a transaction.
  41. public function up()
  42. {
  43. }
  44. public function down()
  45. {
  46. echo "M221124013130InsertQimallCrontabTask cannot be reverted.\n";
  47. return false;
  48. }
  49. */
  50. }