M240705101952AlterQimallAddonsStoreAdmin.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use addons\Store\common\models\StoreAdmin;
  4. use yii\db\Migration;
  5. /**
  6. * Class M240705101952AlterQimallAddonsStoreAdmin
  7. */
  8. class M240705101952AlterQimallAddonsStoreAdmin extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $start = 1000001;
  16. $sql="alter table qimall_addons_store_admin auto_increment = {$start}";
  17. $this->execute($sql);
  18. $list = StoreAdmin::lists(['where' => [['>', 'id', 0]]], false);
  19. foreach ($list as $item) {
  20. $item->id = $start++;
  21. $item->save();
  22. }
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function safeDown()
  28. {
  29. echo "M240705101952AlterQimallAddonsStoreAdmin cannot be reverted.\n";
  30. return false;
  31. }
  32. /*
  33. // Use up()/down() to run migration code without a transaction.
  34. public function up()
  35. {
  36. }
  37. public function down()
  38. {
  39. echo "M240705101952AlterQimallAddonsStoreAdmin cannot be reverted.\n";
  40. return false;
  41. }
  42. */
  43. }