M230705071445WangDianTongCrontabTask.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace addons\WangDianTong\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230705071445WangDianTongCrontabTask
  6. */
  7. class M230705071445WangDianTongCrontabTask extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $list = $this->db->createCommand("select * from qimall_crontab_task where
  15. `command` IN ('wang-dian-tong/logistics-task/sync',
  16. 'wang-dian-tong/compensate-task/sync') ")->queryAll();
  17. if($list && count($list) == 2) return true;
  18. $this->execute("INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('旺店通 - 每5分钟同步一次发货信息', 'wang-dian-tong/logistics-task/sync', 2, '0 */5 * * * *', 0, 1, 1684307540, 1684307544);");
  19. $this->execute("INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('旺店通 - 同步数据失败每5分钟补偿一次', 'wang-dian-tong/compensate-task/sync', 2, '0 */5 * * * *', 0, 1, 1684307500, 1684307500);");
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function safeDown()
  25. {
  26. echo "M230705071445WangDianTongCrontabTask cannot be reverted.\n";
  27. return false;
  28. }
  29. /*
  30. // Use up()/down() to run migration code without a transaction.
  31. public function up()
  32. {
  33. }
  34. public function down()
  35. {
  36. echo "M230705071445WangDianTongCrontabTask cannot be reverted.\n";
  37. return false;
  38. }
  39. */
  40. }