M240703030607UpdateExpressSort.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M240703030607UpdateExpressSort
  6. */
  7. class M240703030607UpdateExpressSort extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $sql = <<<SQL
  15. UPDATE `qimall_express` SET `sort` = 1 WHERE `id` = 1;
  16. UPDATE `qimall_express` SET `sort` = 2 WHERE `id` = 2;
  17. UPDATE `qimall_express` SET `sort` = 3 WHERE `id` = 3;
  18. UPDATE `qimall_express` SET `sort` = 4 WHERE `id` = 5;
  19. UPDATE `qimall_express` SET `sort` = 5 WHERE `id` = 6;
  20. UPDATE `qimall_express` SET `sort` = 6 WHERE `id` = 7;
  21. UPDATE `qimall_express` SET `sort` = 7 WHERE `id` = 4;
  22. UPDATE `qimall_express` SET `sort` = 8 WHERE `id` = 103;
  23. UPDATE `qimall_express` SET `sort` = 9 WHERE `id` = 18;
  24. SQL;
  25. $this->execute($sql);
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function safeDown()
  31. {
  32. return false;
  33. }
  34. /*
  35. // Use up()/down() to run migration code without a transaction.
  36. public function up()
  37. {
  38. }
  39. public function down()
  40. {
  41. echo "M240703030607UpdateExpressSort cannot be reverted.\n";
  42. return false;
  43. }
  44. */
  45. }