M221230065148UpdateContentToDiy.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. *
  6. * Class M221230065148UpdateContentToDiy
  7. */
  8. class M221230065148UpdateContentToDiy extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $sql = "set @old_url = '/plugins/Store/';
  16. set @new_url = '/plugins2/Store/';
  17. UPDATE `qimall_diy_page` SET content=REPLACE(content, @old_url, @new_url) where content like concat(\"%\",@old_url,\"%\");
  18. UPDATE qimall_addons_marketing_setting set content=REPLACE(content, @old_url, @new_url) where content like concat(\"%\",@old_url,\"%\");";
  19. $this->execute($sql);
  20. $sql = "set @old_url = '/plugins/Card/';
  21. set @new_url = '/plugins2/Card/';
  22. UPDATE `qimall_diy_page` SET content=REPLACE(content, @old_url, @new_url) where content like concat(\"%\",@old_url,\"%\");
  23. UPDATE qimall_addons_marketing_setting set content=REPLACE(content, @old_url, @new_url) where content like concat(\"%\",@old_url,\"%\");";
  24. $this->execute($sql);
  25. $sql = "set @old_url = '/plugins/Pk/';
  26. set @new_url = '/plugins2/Pk/';
  27. UPDATE `qimall_diy_page` SET content=REPLACE(content, @old_url, @new_url) where content like concat(\"%\",@old_url,\"%\");
  28. UPDATE qimall_addons_marketing_setting set content=REPLACE(content, @old_url, @new_url) where content like concat(\"%\",@old_url,\"%\");";
  29. $this->execute($sql);
  30. $sql = "set @old_url = '/plugins/ElectronCoupon/';
  31. set @new_url = '/plugins2/ElectronCoupon/';
  32. UPDATE `qimall_diy_page` SET content=REPLACE(content, @old_url, @new_url) where content like concat(\"%\",@old_url,\"%\");
  33. UPDATE qimall_addons_marketing_setting set content=REPLACE(content, @old_url, @new_url) where content like concat(\"%\",@old_url,\"%\");";
  34. $this->execute($sql);
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function safeDown()
  40. {
  41. echo "M221230065148UpdateContentToDiy cannot be reverted.\n";
  42. return false;
  43. }
  44. /*
  45. // Use up()/down() to run migration code without a transaction.
  46. public function up()
  47. {
  48. }
  49. public function down()
  50. {
  51. echo "M221230065148UpdateContentToDiy cannot be reverted.\n";
  52. return false;
  53. }
  54. */
  55. }