M240320021647InsertTask.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace addons\SecondaryCard\console\migrations;
  3. use common\models\common\CrontabTask;
  4. use yii\db\Migration;
  5. /**
  6. * Class M240320021647InsertTask
  7. */
  8. class M240320021647InsertTask extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $res = CrontabTask::find()->where(['command'=>'secondary-card/index-crontab/order-refund'])->one();
  16. if(empty($res)) {
  17. $sql="INSERT INTO `qimall_crontab_task` (`name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ( '次卡过期检查', 'secondary-card/index-crontab/order-refund', 2, '0 */1 * * * *', 0, 1, 1710494060, 1710494060);";
  18. $this->execute($sql);
  19. }
  20. $res = CrontabTask::find()->where(['command'=>'secondary-card/index-crontab/put-down'])->one();
  21. if(empty($res)) {
  22. $sql="
  23. INSERT INTO `qimall_crontab_task` ( `name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('次卡检查下架', 'secondary-card/index-crontab/put-down', 2, '0 */1 * * * *', 0, 1, 1712718662, 1712718662);
  24. ";
  25. $this->execute($sql);
  26. }
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function safeDown()
  32. {
  33. echo "M240320021647InsertTask cannot be reverted.\n";
  34. return false;
  35. }
  36. /*
  37. // Use up()/down() to run migration code without a transaction.
  38. public function up()
  39. {
  40. }
  41. public function down()
  42. {
  43. echo "M240320021647InsertTask cannot be reverted.\n";
  44. return false;
  45. }
  46. */
  47. }