M230705071957BusinessActivityCrontabTask.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace addons\BusinessActivity\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230705071957BusinessActivityCrontabTask
  6. */
  7. class M230705071957BusinessActivityCrontabTask 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 ('business-activity/activity/sign-in-expire',
  16. 'business-activity/activity/activity-finish') ")->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 ('招商活动 - 定时解除绑定关系', 'business-activity/activity/sign-in-expire', 2, '0 */1 * * * *', 0, 1, 1678879219, 1678879219);");
  19. $this->execute("INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('招商活动 - 定时启用/结束', 'business-activity/activity/activity-finish', 2, '0 */1 * * * *', 0, 1, 1678879140, 1678879140);");
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function safeDown()
  25. {
  26. echo "M230705071957BusinessActivityCrontabTask 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 "M230705071957BusinessActivityCrontabTask cannot be reverted.\n";
  37. return false;
  38. }
  39. */
  40. }