M230821025254InsertQimallRegion.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace app\migrations;
  3. use common\models\common\Region;
  4. use common\models\user\Town;
  5. use yii\db\Migration;
  6. /**
  7. * Class M230821025254InsertQimallRegion
  8. */
  9. class M230821025254InsertQimallRegion extends Migration
  10. {
  11. /**
  12. * {@inheritdoc}
  13. */
  14. public function safeUp()
  15. {
  16. try {
  17. $sql = "INSERT INTO `qimall_region`(`id`, `name`, `parent_id`, `level`, `short_title`, `areacode`, `zipcode`, `initial`, `lng`, `lat`, `created_at`, `updated_at`) VALUES
  18. (10074, '临平区', 922, 3, '', 0, 0, '', '', '', 1695434148, 1695434148),
  19. (10075, '钱塘区', 922, 3, '', 0, 0, '', '', '', 1695434148, 1695434148);";
  20. $this->execute($sql);
  21. $town_sql = "INSERT INTO `qimall_town`(`id`, `district_id`, `adcode`, `name`, `created_at`, `updated_at`) VALUES
  22. (39157, 10074, 330113, '临平街道', 1695434148, 1695434148),
  23. (39158, 10074, 330113, '南苑街道', 1695434148, 1695434148),
  24. (39159, 10074, 330113, '东湖街道', 1695434148, 1695434148),
  25. (39160, 10074, 330113, '星桥街道', 1695434148, 1695434148),
  26. (39161, 10074, 330113, '乔司街道', 1695434148, 1695434148),
  27. (39162, 10074, 330113, '运河街道', 1695434148, 1695434148),
  28. (39163, 10074, 330113, '崇贤街道', 1695434148, 1695434148),
  29. (39164, 10074, 330113, '塘栖镇', 1695434148, 1695434148),
  30. (39165, 10075, 330114, '下沙街道', 1695434148, 1695434148),
  31. (39166, 10075, 330114, '白杨街道', 1695434148, 1695434148),
  32. (39167, 10075, 330114, '河庄街道', 1695434148, 1695434148),
  33. (39168, 10075, 330114, '义蓬街道', 1695434148, 1695434148),
  34. (39169, 10075, 330114, '新湾街道', 1695434148, 1695434148),
  35. (39170, 10075, 330114, '临江街道', 1695434148, 1695434148),
  36. (39171, 10075, 330114, '前进街道', 1695434148, 1695434148);";
  37. $this->execute($town_sql);
  38. } catch (\Exception $e) {
  39. }
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function safeDown()
  45. {
  46. echo "M230821025254InsertQimallRegion cannot be reverted.\n";
  47. return false;
  48. }
  49. /*
  50. // Use up()/down() to run migration code without a transaction.
  51. public function up()
  52. {
  53. }
  54. public function down()
  55. {
  56. echo "M230821025254InsertQimallRegion cannot be reverted.\n";
  57. return false;
  58. }
  59. */
  60. }