From 1041c43fb1afbdb70d651052ffd9fe8b37a47ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Fri, 14 Oct 2022 10:51:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221013045836_install_postage.php | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/database/migrations/20221013045836_install_postage.php b/database/migrations/20221013045836_install_postage.php index 5b84c563b..a8cd024f5 100644 --- a/database/migrations/20221013045836_install_postage.php +++ b/database/migrations/20221013045836_install_postage.php @@ -54,16 +54,30 @@ class InstallPostage extends Migrator 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-快递-区域', ]) ->addColumn('pid', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '上级PID']) - ->addColumn('first', 'string', ['limit' => 50, 'default' => '', 'comment' => '首字母']) - ->addColumn('short', 'string', ['limit' => 100, 'default' => '', 'comment' => '区域简称']) - ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'comment' => '区域名称']) - ->addColumn('level', 'integer', ['limit' => 4, 'default' => 0, 'comment' => '区域层级']) - ->addColumn('pinyin', 'string', ['limit' => 100, 'default' => '', 'comment' => '区域拼音']) - ->addColumn('code', 'string', ['limit' => 100, 'default' => '', 'comment' => '区域邮编']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '使用状态']) ->addColumn('lng', 'string', ['limit' => 100, 'default' => '', 'comment' => '所在经度']) ->addColumn('lat', 'string', ['limit' => 100, 'default' => '', 'comment' => '所在纬度']) + ->addColumn('code', 'string', ['limit' => 100, 'default' => '', 'comment' => '区域邮编']) + ->addColumn('first', 'string', ['limit' => 50, 'default' => '', 'comment' => '首字母']) + ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'comment' => '区域名称']) + ->addColumn('short', 'string', ['limit' => 100, 'default' => '', 'comment' => '区域简称']) + ->addColumn('level', 'integer', ['limit' => 4, 'default' => 0, 'comment' => '区域层级']) + ->addColumn('pinyin', 'string', ['limit' => 100, 'default' => '', 'comment' => '区域拼音']) + ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '使用状态']) + ->addIndex('pid', ['name' => 'idx_base_postage_region_pid']) + ->addIndex('status', ['name' => 'idx_base_postage_region_status']) ->save(); + + // 写入默认区域数据 + $this->_insert_region($table); + } + + /** + * 写入默认区域数据 + * @param string $table + * @return void + */ + private function _insert_region(string $table) + { $this->execute(<<