| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace app\migrations;
- use yii\db\Migration;
- /**
- * 因为区域管理表不是自增Id。所以需要指定ID 之前有错误数据需要删除
- * Class M250610102639InsertRegion
- */
- class M250610102639InsertRegion extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- // 先执行之前数据的删除 在重新插入
- try {
- $sql = <<<SQL
- DELETE FROM `qimall_region` WHERE `name` = '大亚湾经济技术开发区' OR `name` = '仲恺高新技术产业开发区';
- INSERT INTO `qimall_region` (`id`, `name`, `parent_id`, `level`, `short_title`, `areacode`, `zipcode`, `initial`, `lng`, `lat`) VALUES (10320, '大亚湾经济技术开发区',2025,3,'',0,0,'D','114.52193199999','22.715671999999');
- INSERT INTO `qimall_region` (`id`, `name`, `parent_id`, `level`, `short_title`, `areacode`, `zipcode`, `initial`, `lng`, `lat`) VALUES (10321, '仲恺高新技术产业开发区',2025,3,'',0,0,'Z','114.29527199999','23.034215000000');
- SQL;
- $this->execute($sql);
- } catch (\Exception $e) {
- }
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M250610102639InsertRegion cannot be reverted.\n";
- return false;
- }
- }
|