From 34262095fe50db668c2bfaa177bd0625b1c5b15c 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 13:10:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 2 +- .../20221013031925_install_admin.php | 88 ++++---- .../20221013045829_install_wechat.php | 202 ++++++++++-------- .../20221013045836_install_postage.php | 31 +-- .../20221013045838_install_user.php | 63 ++++-- .../20221013075924_install_news.php | 48 +++-- .../20221013080600_install_shop.php | 124 +++++++---- 7 files changed, 337 insertions(+), 221 deletions(-) diff --git a/composer.json b/composer.json index 7a9c7c43f..1b3e5bf4f 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "topthink/think-view": "^1.0", "topthink/think-migration": "^3.0", "zoujingli/ip2region": "^2.0", - "zoujingli/think-library": "^6.0.37", + "zoujingli/think-library": "6.0.x-dev", "zoujingli/wechat-developer": "^1.2" }, "autoload": { diff --git a/database/migrations/20221013031925_install_admin.php b/database/migrations/20221013031925_install_admin.php index b07797813..3112db9ac 100644 --- a/database/migrations/20221013031925_install_admin.php +++ b/database/migrations/20221013031925_install_admin.php @@ -134,26 +134,32 @@ SQL private function _data() { - // 当前操作 + // 当前数据表 $table = 'system_data'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '系统-数据', ]) ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'comment' => '配置名']) - ->addColumn('value', 'text', ['default' => '', 'comment' => '配置值']) + ->addColumn('value', 'text', ['default' => null, 'comment' => '配置值']) ->addIndex('name', ['name' => 'idx_system_data_name']) ->save(); } private function _file() { - // 当前操作 + // 当前数据表 $table = 'system_file'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '系统-文件', ]) ->addColumn('type', 'string', ['limit' => 20, 'default' => '', 'comment' => '上传类型']) @@ -166,10 +172,10 @@ SQL ->addColumn('size', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '文件大小']) ->addColumn('uuid', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '用户编号']) ->addColumn('isfast', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '是否秒传']) - ->addColumn('issafe', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '是否安全模式']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态(0禁用,1启用)']) - ->addColumn('create_at', 'datetime', ['limit' => 20, 'default' => '', 'comment' => '创建时间']) - ->addColumn('update_at', 'datetime', ['limit' => 20, 'default' => 0, 'comment' => '更新时间']) + ->addColumn('issafe', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '安全模式']) + ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '上传状态(1悬空,2落地)']) + ->addColumn('create_at', 'datetime', ['default' => null, 'comment' => '创建时间']) + ->addColumn('update_at', 'datetime', ['default' => null, 'comment' => '更新时间']) ->addIndex('type', ['name' => 'idx_system_file_type']) ->addIndex('hash', ['name' => 'idx_system_file_hash']) ->addIndex('uuid', ['name' => 'idx_system_file_uuid']) @@ -182,7 +188,7 @@ SQL private function _menu() { - // 当前操作 + // 当前数据表 $table = 'system_menu'; // 存在则跳过 @@ -192,19 +198,19 @@ SQL $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '系统-菜单', ]) - ->addColumn('pid', 'integer', ['limit' => 20, 'default' => 1, 'comment' => '上级编号']) + ->addColumn('pid', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '上级ID']) ->addColumn('title', 'string', ['limit' => 100, 'default' => '', 'comment' => '菜单名称']) ->addColumn('icon', 'string', ['limit' => 100, 'default' => '', 'comment' => '菜单图标']) ->addColumn('node', 'string', ['limit' => 100, 'default' => '', 'comment' => '节点代码']) - ->addColumn('url', 'string', ['limit' => 500, 'default' => '', 'comment' => '链接节点']) + ->addColumn('url', 'string', ['limit' => 400, 'default' => '', 'comment' => '链接节点']) ->addColumn('params', 'string', ['limit' => 500, 'default' => '', 'comment' => '链接参数']) ->addColumn('target', 'string', ['limit' => 20, 'default' => '_self', 'comment' => '打开方式']) - ->addColumn('sort', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态(0禁用,1启用)']) + ->addColumn('sort', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '排序权重']) + ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态(0:禁用,1:启用)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) - ->addIndex('pid', ['name' => 'idx_system_menu_pid']) - ->addIndex('sort', ['name' => 'idx_system_menu_sort']) ->addIndex('status', ['name' => 'idx_system_menu_status']) + ->addIndex('sort', ['name' => 'idx_system_menu_sort']) + ->addIndex('pid', ['name' => 'idx_system_menu_pid']) ->save(); // 初始化菜单数据 @@ -260,15 +266,18 @@ SQL private function _oplog() { - // 当前操作 + // 当前数据表 $table = 'system_oplog'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '系统-日志', ]) ->addColumn('node', 'string', ['limit' => 200, 'default' => '', 'comment' => '当前操作节点']) - ->addColumn('geoip', 'string', ['limit' => 20, 'default' => '', 'comment' => '操作者IP地址']) + ->addColumn('geoip', 'string', ['limit' => 15, 'default' => '', 'comment' => '操作者IP地址']) ->addColumn('action', 'string', ['limit' => 200, 'default' => '', 'comment' => '操作行为名称']) ->addColumn('content', 'string', ['limit' => 1024, 'default' => '', 'comment' => '操作内容描述']) ->addColumn('username', 'string', ['limit' => 50, 'default' => '', 'comment' => '操作人用户名']) @@ -278,38 +287,42 @@ SQL private function _queue() { - // 当前操作 + // 当前数据表 $table = 'system_queue'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '系统-任务', ]) ->addColumn('code', 'string', ['limit' => 20, 'default' => '', 'comment' => '任务编号']) ->addColumn('title', 'string', ['limit' => 100, 'default' => '', 'comment' => '任务名称']) ->addColumn('command', 'string', ['limit' => 500, 'default' => '', 'comment' => '执行指令']) ->addColumn('exec_pid', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '执行进程']) - ->addColumn('exec_data', 'text', ['default' => '', 'comment' => '执行参数']) + ->addColumn('exec_data', 'text', ['default' => null, 'comment' => '执行参数']) ->addColumn('exec_time', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '执行时间']) ->addColumn('exec_desc', 'string', ['limit' => 500, 'default' => '', 'comment' => '执行描述']) - ->addColumn('enter_time', 'decimal', ['precision' => 20, 'scale' => 4, 'default' => 0, 'comment' => '开始时间']) - ->addColumn('outer_time', 'decimal', ['precision' => 20, 'scale' => 4, 'default' => 0, 'comment' => '结束时间']) + ->addColumn('enter_time', 'decimal', ['precision' => 20, 'scale' => 4, 'default' => '0.0000', 'comment' => '开始时间']) + ->addColumn('outer_time', 'decimal', ['precision' => 20, 'scale' => 4, 'default' => '0.0000', 'comment' => '结束时间']) ->addColumn('loops_time', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '循环时间']) ->addColumn('attempts', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '执行次数']) - ->addColumn('rscript', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '任务类型(0单例,1多例)']) + ->addColumn('rscript', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '任务类型(0单例,1多例)']) ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '任务状态(1新任务,2处理中,3成功,4失败)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addIndex('code', ['name' => 'idx_system_queue_code']) ->addIndex('title', ['name' => 'idx_system_queue_title']) ->addIndex('status', ['name' => 'idx_system_queue_status']) - ->addIndex('exec_time', ['name' => 'idx_system_queue_exec_time']) + ->addIndex('rscript', ['name' => 'idx_system_queue_rscript']) ->addIndex('create_at', ['name' => 'idx_system_queue_create_at']) + ->addIndex('exec_time', ['name' => 'idx_system_queue_exec_time']) ->save(); } private function _user() { - // 当前操作 + // 当前数据表 $table = 'system_user'; // 存在则跳过 @@ -318,26 +331,27 @@ SQL // 创建数据表 $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '系统-用户', - ])->addColumn('usertype', 'string', ['limit' => 20, 'default' => '', 'comment' => '用户类型']) + ]) + ->addColumn('usertype', 'string', ['limit' => 20, 'default' => '', 'comment' => '用户类型']) ->addColumn('username', 'string', ['limit' => 50, 'default' => '', 'comment' => '用户账号']) ->addColumn('password', 'string', ['limit' => 32, 'default' => '', 'comment' => '用户密码']) ->addColumn('nickname', 'string', ['limit' => 50, 'default' => '', 'comment' => '用户昵称']) - ->addColumn('headimg', 'string', ['limit' => 500, 'default' => '', 'comment' => '头像地址']) - ->addColumn('authorize', 'string', ['limit' => 500, 'default' => '', 'comment' => '权限授权']) + ->addColumn('headimg', 'string', ['limit' => 255, 'default' => '', 'comment' => '头像地址']) + ->addColumn('authorize', 'string', ['limit' => 255, 'default' => '', 'comment' => '权限授权']) ->addColumn('contact_qq', 'string', ['limit' => 20, 'default' => '', 'comment' => '联系QQ']) ->addColumn('contact_mail', 'string', ['limit' => 20, 'default' => '', 'comment' => '联系邮箱']) ->addColumn('contact_phone', 'string', ['limit' => 20, 'default' => '', 'comment' => '联系手机']) - ->addColumn('login_ip', 'string', ['limit' => 20, 'default' => '', 'comment' => '登录地址']) + ->addColumn('login_ip', 'string', ['limit' => 255, 'default' => '', 'comment' => '登录地址']) ->addColumn('login_at', 'string', ['limit' => 20, 'default' => '', 'comment' => '登录时间']) ->addColumn('login_num', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '登录次数']) - ->addColumn('describe', 'string', ['limit' => 500, 'default' => '', 'comment' => '备注说明']) + ->addColumn('describe', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注说明']) ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态(0禁用,1启用)']) ->addColumn('sort', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '排序权重']) ->addColumn('is_deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '删除(1删除,0未删)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addIndex('status', ['name' => 'idx_system_user_status']) ->addIndex('username', ['name' => 'idx_system_user_username']) - ->addIndex('is_deleted', ['name' => 'idx_system_user_deleted']) + ->addIndex('is_deleted', ['name' => 'idx_system_user_is_deleted']) ->save(); // 初始化默认数据 diff --git a/database/migrations/20221013045829_install_wechat.php b/database/migrations/20221013045829_install_wechat.php index 17993919b..46ae91f52 100644 --- a/database/migrations/20221013045829_install_wechat.php +++ b/database/migrations/20221013045829_install_wechat.php @@ -20,188 +20,204 @@ class InstallWechat extends Migrator private function _auto() { - // 当前操作 + // 当前数据表 $table = 'wechat_auto'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信-回复', ]) ->addColumn('type', 'string', ['limit' => 20, 'default' => '', 'comment' => '类型(text,image,news)']) - ->addColumn('time', 'string', ['limit' => 50, 'default' => '', 'comment' => '延迟时间']) + ->addColumn('time', 'string', ['limit' => 100, 'default' => '', 'comment' => '延迟时间']) ->addColumn('code', 'string', ['limit' => 20, 'default' => '', 'comment' => '消息编号']) - ->addColumn('appid', 'string', ['limit' => 50, 'default' => '', 'comment' => '公众号编号']) - ->addColumn('content', 'text', ['default' => '', 'comment' => '文本内容']) - ->addColumn('image_url', 'string', ['limit' => 500, 'default' => '', 'comment' => '图片链接']) - ->addColumn('voice_url', 'string', ['limit' => 500, 'default' => '', 'comment' => '语音链接']) - ->addColumn('music_title', 'string', ['limit' => 500, 'default' => '', 'comment' => '音乐标题']) - ->addColumn('music_url', 'string', ['limit' => 500, 'default' => '', 'comment' => '音乐链接']) - ->addColumn('music_image', 'string', ['limit' => 500, 'default' => '', 'comment' => '缩略图片']) - ->addColumn('music_desc', 'string', ['limit' => 500, 'default' => '', 'comment' => '音乐描述']) - ->addColumn('video_title', 'string', ['limit' => 500, 'default' => '', 'comment' => '视频标题']) - ->addColumn('video_url', 'string', ['limit' => 500, 'default' => '', 'comment' => '视频链接']) - ->addColumn('video_desc', 'string', ['limit' => 500, 'default' => '', 'comment' => '视频描述']) - ->addColumn('news_id', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '图文编号']) + ->addColumn('appid', 'char(100)', ['default' => '', 'comment' => '公众号APPID']) + ->addColumn('content', 'text', ['default' => null, 'comment' => '文本内容']) + ->addColumn('image_url', 'string', ['limit' => 255, 'default' => '', 'comment' => '图片链接']) + ->addColumn('voice_url', 'string', ['limit' => 255, 'default' => '', 'comment' => '语音链接']) + ->addColumn('music_title', 'string', ['limit' => 100, 'default' => '', 'comment' => '音乐标题']) + ->addColumn('music_url', 'string', ['limit' => 255, 'default' => '', 'comment' => '音乐链接']) + ->addColumn('music_image', 'string', ['limit' => 255, 'default' => '', 'comment' => '缩略图片']) + ->addColumn('music_desc', 'string', ['limit' => 255, 'default' => '', 'comment' => '音乐描述']) + ->addColumn('video_title', 'string', ['limit' => 100, 'default' => '', 'comment' => '视频标题']) + ->addColumn('video_url', 'string', ['limit' => 255, 'default' => '', 'comment' => '视频URL']) + ->addColumn('video_desc', 'string', ['limit' => 255, 'default' => '', 'comment' => '视频描述']) + ->addColumn('news_id', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '图文ID']) ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态(0禁用,1启用)']) + ->addColumn('create_by', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '创建人']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) - ->addIndex('code', ['name' => 'idx_wechat_auto_code']) ->addIndex('type', ['name' => 'idx_wechat_auto_type']) ->addIndex('time', ['name' => 'idx_wechat_auto_time']) + ->addIndex('code', ['name' => 'idx_wechat_auto_code']) ->addIndex('appid', ['name' => 'idx_wechat_auto_appid']) - ->addIndex('status', ['name' => 'idx_wechat_auto_status']) ->save(); } private function _fans() { - // 当前操作 + // 当前数据表 $table = 'wechat_fans'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信-粉丝', ]) - ->addColumn('appid', 'string', ['limit' => 50, 'default' => '', 'comment' => '公众号编号']) - ->addColumn('unionid', 'string', ['limit' => 100, 'default' => '', 'comment' => 'UNIONID']) - ->addColumn('openid', 'string', ['limit' => 100, 'default' => '', 'comment' => 'OPENID']) - ->addColumn('tagid_list', 'string', ['limit' => 100, 'default' => '', 'comment' => '粉丝标签']) - ->addColumn('is_black', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '黑名单状态']) - ->addColumn('subscribe', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '黑名单状态']) + ->addColumn('appid', 'string', ['limit' => 50, 'default' => '', 'comment' => '公众号APPID']) + ->addColumn('unionid', 'string', ['limit' => 100, 'default' => '', 'comment' => '粉丝unionid']) + ->addColumn('openid', 'string', ['limit' => 100, 'default' => '', 'comment' => '粉丝openid']) + ->addColumn('tagid_list', 'string', ['limit' => 100, 'default' => '', 'comment' => '粉丝标签id']) + ->addColumn('is_black', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '是否为黑名单状态']) + ->addColumn('subscribe', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '关注状态(0未关注,1已关注)']) ->addColumn('nickname', 'string', ['limit' => 200, 'default' => '', 'comment' => '用户昵称']) ->addColumn('sex', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '用户性别(1男性,2女性,0未知)']) ->addColumn('country', 'string', ['limit' => 50, 'default' => '', 'comment' => '用户所在国家']) ->addColumn('province', 'string', ['limit' => 50, 'default' => '', 'comment' => '用户所在省份']) ->addColumn('city', 'string', ['limit' => 50, 'default' => '', 'comment' => '用户所在城市']) - ->addColumn('language', 'string', ['limit' => 50, 'default' => '', 'comment' => '用户的语言']) + ->addColumn('language', 'string', ['limit' => 50, 'default' => '', 'comment' => '用户的语言(zh_CN)']) ->addColumn('headimgurl', 'string', ['limit' => 500, 'default' => '', 'comment' => '用户头像']) ->addColumn('subscribe_time', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '关注时间']) - ->addColumn('subscribe_at', 'datetime', ['limit' => 20, 'default' => null, 'comment' => '关注时间']) - ->addColumn('subscribe_scene', 'string', ['limit' => 200, 'default' => '', 'comment' => '扫码场景']) - ->addColumn('qr_scene', 'string', ['limit' => 200, 'default' => '', 'comment' => '场景数值']) - ->addColumn('qr_scene_str', 'string', ['limit' => 200, 'default' => '', 'comment' => '场景内容']) - ->addColumn('remark', 'string', ['limit' => 500, 'default' => '', 'comment' => '用户备注']) + ->addColumn('subscribe_at', 'datetime', ['default' => null, 'comment' => '关注时间']) + ->addColumn('remark', 'string', ['limit' => 50, 'default' => '', 'comment' => '备注']) + ->addColumn('subscribe_scene', 'string', ['limit' => 200, 'default' => '', 'comment' => '扫码关注场景']) + ->addColumn('qr_scene', 'string', ['limit' => 100, 'default' => '', 'comment' => '二维码场景值']) + ->addColumn('qr_scene_str', 'string', ['limit' => 200, 'default' => '', 'comment' => '二维码场景内容']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) - ->addIndex('appid', ['name' => 'idx_wechat_fans_appid']) ->addIndex('openid', ['name' => 'idx_wechat_fans_openid']) ->addIndex('unionid', ['name' => 'idx_wechat_fans_unionid']) - ->addIndex('is_black', ['name' => 'idx_wechat_fans_black']) + ->addIndex('is_black', ['name' => 'idx_wechat_fans_is_black']) ->addIndex('subscribe', ['name' => 'idx_wechat_fans_subscribe']) ->save(); } private function _tags() { - // 当前操作 + // 当前数据表 $table = 'wechat_fans_tags'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信-标签', ]) - ->addColumn('appid', 'string', ['limit' => 50, 'default' => '', 'comment' => '公众号编号']) - ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '标签名称']) - ->addColumn('openid', 'string', ['limit' => 100, 'default' => '', 'comment' => 'OPENID']) - ->addColumn('count', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '粉丝数量']) - ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) - ->addIndex('appid', ['name' => 'idx_wechat_fans_appid']) + ->addColumn('appid', 'string', ['limit' => 50, 'default' => '', 'comment' => '公众号APPID']) + ->addColumn('name', 'string', ['limit' => 35, 'default' => null, 'comment' => '标签名称']) + ->addColumn('count', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '总数']) + ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建日期']) + ->addIndex('id', ['name' => 'idx_wechat_fans_tags_id']) + ->addIndex('appid', ['name' => 'idx_wechat_fans_tags_appid']) ->save(); } private function _keys() { - // 当前操作 + // 当前数据表 $table = 'wechat_keys'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信-规则', ]) + ->addColumn('appid', 'char(100)', ['default' => '', 'comment' => '公众号APPID']) ->addColumn('type', 'string', ['limit' => 20, 'default' => '', 'comment' => '类型(text,image,news)']) - ->addColumn('keys', 'string', ['limit' => 100, 'default' => '', 'comment' => '关键字']) - ->addColumn('appid', 'string', ['limit' => 50, 'default' => '', 'comment' => '公众号编号']) - ->addColumn('content', 'text', ['default' => '', 'comment' => '文本内容']) - ->addColumn('image_url', 'string', ['limit' => 500, 'default' => '', 'comment' => '图片链接']) - ->addColumn('voice_url', 'string', ['limit' => 500, 'default' => '', 'comment' => '语音链接']) - ->addColumn('music_title', 'string', ['limit' => 500, 'default' => '', 'comment' => '音乐标题']) - ->addColumn('music_url', 'string', ['limit' => 500, 'default' => '', 'comment' => '音乐链接']) - ->addColumn('music_image', 'string', ['limit' => 500, 'default' => '', 'comment' => '缩略图片']) - ->addColumn('music_desc', 'string', ['limit' => 500, 'default' => '', 'comment' => '音乐描述']) - ->addColumn('video_title', 'string', ['limit' => 500, 'default' => '', 'comment' => '视频标题']) - ->addColumn('video_url', 'string', ['limit' => 500, 'default' => '', 'comment' => '视频链接']) - ->addColumn('video_desc', 'string', ['limit' => 500, 'default' => '', 'comment' => '视频描述']) - ->addColumn('news_id', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '图文编号']) - ->addColumn('sort', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '排序权重']) + ->addColumn('keys', 'string', ['limit' => 100, 'default' => null, 'comment' => '关键字']) + ->addColumn('content', 'text', ['default' => null, 'comment' => '文本内容']) + ->addColumn('image_url', 'string', ['limit' => 255, 'default' => '', 'comment' => '图片链接']) + ->addColumn('voice_url', 'string', ['limit' => 255, 'default' => '', 'comment' => '语音链接']) + ->addColumn('music_title', 'string', ['limit' => 100, 'default' => '', 'comment' => '音乐标题']) + ->addColumn('music_url', 'string', ['limit' => 255, 'default' => '', 'comment' => '音乐链接']) + ->addColumn('music_image', 'string', ['limit' => 255, 'default' => '', 'comment' => '缩略图片']) + ->addColumn('music_desc', 'string', ['limit' => 255, 'default' => '', 'comment' => '音乐描述']) + ->addColumn('video_title', 'string', ['limit' => 100, 'default' => '', 'comment' => '视频标题']) + ->addColumn('video_url', 'string', ['limit' => 255, 'default' => '', 'comment' => '视频URL']) + ->addColumn('video_desc', 'string', ['limit' => 255, 'default' => '', 'comment' => '视频描述']) + ->addColumn('news_id', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '图文ID']) + ->addColumn('sort', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '排序字段']) ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态(0禁用,1启用)']) - ->addColumn('create_by', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '创建用户']) + ->addColumn('create_by', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '创建人']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) - ->addIndex('sort', ['name' => 'idx_wechat_keys_sort']) - ->addIndex('keys', ['name' => 'idx_wechat_keys_keys']) - ->addIndex('type', ['name' => 'idx_wechat_keys_type']) - ->addIndex('time', ['name' => 'idx_wechat_keys_time']) ->addIndex('appid', ['name' => 'idx_wechat_keys_appid']) - ->addIndex('status', ['name' => 'idx_wechat_keys_status']) + ->addIndex('type', ['name' => 'idx_wechat_keys_type']) + ->addIndex('keys', ['name' => 'idx_wechat_keys_keys']) ->save(); } private function _media() { - // 当前操作 + // 当前数据表 $table = 'wechat_media'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信-素材', ]) - ->addColumn('md5', 'string', ['limit' => 32, 'default' => '', 'comment' => '文件哈希']) + ->addColumn('md5', 'string', ['limit' => 32, 'default' => '', 'comment' => '文件md5']) ->addColumn('type', 'string', ['limit' => 20, 'default' => '', 'comment' => '媒体类型']) - ->addColumn('appid', 'string', ['limit' => 50, 'default' => '', 'comment' => '公众号编号']) + ->addColumn('appid', 'string', ['limit' => 100, 'default' => '', 'comment' => '公众号ID']) ->addColumn('media_id', 'string', ['limit' => 100, 'default' => '', 'comment' => '永久素材MediaID']) - ->addColumn('local_url', 'string', ['limit' => 500, 'default' => '', 'comment' => '本地文件链接']) - ->addColumn('media_url', 'string', ['limit' => 500, 'default' => '', 'comment' => '远程图片链接']) + ->addColumn('local_url', 'string', ['limit' => 300, 'default' => '', 'comment' => '本地文件链接']) + ->addColumn('media_url', 'string', ['limit' => 300, 'default' => '', 'comment' => '远程图片链接']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) + ->addIndex('appid', ['name' => 'idx_wechat_media_appid']) ->addIndex('md5', ['name' => 'idx_wechat_media_md5']) ->addIndex('type', ['name' => 'idx_wechat_media_type']) - ->addIndex('appid', ['name' => 'idx_wechat_media_appid']) - ->addIndex('media_id', ['name' => 'idx_wechat_media_id']) + ->addIndex('media_id', ['name' => 'idx_wechat_media_media_id']) ->save(); } private function _news() { - // 当前操作 + // 当前数据表 $table = 'wechat_news'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信-图文', ]) - ->addColumn('media_id', 'string', ['limit' => 100, 'default' => '', 'comment' => '永久素材编号']) - ->addColumn('local_url', 'string', ['limit' => 500, 'default' => '', 'comment' => '本地文件链接']) - ->addColumn('article_id', 'string', ['limit' => 100, 'default' => '', 'comment' => '关联文章编号(用英文逗号做分割)']) - ->addColumn('is_deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '删除(1删除,0未删)']) - ->addColumn('create_by', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '创建用户']) + ->addColumn('media_id', 'string', ['limit' => 100, 'default' => '', 'comment' => '永久素材MediaID']) + ->addColumn('local_url', 'string', ['limit' => 300, 'default' => '', 'comment' => '永久素材外网URL']) + ->addColumn('article_id', 'string', ['limit' => 60, 'default' => '', 'comment' => '关联图文ID(用英文逗号做分割)']) + ->addColumn('is_deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '删除状态(0未删除,1已删除)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) - ->addIndex('media_id', ['name' => 'idx_wechat_news_media_id']) + ->addColumn('create_by', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '创建人']) ->addIndex('article_id', ['name' => 'idx_wechat_news_article_id']) - ->addIndex('is_deleted', ['name' => 'idx_wechat_news_deleted']) + ->addIndex('media_id', ['name' => 'idx_wechat_news_media_id']) ->save(); } private function _article() { - // 当前操作 + // 当前数据表 $table = 'wechat_news_article'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '微信-文章', ]) - ->addColumn('title', 'string', ['limit' => 100, 'default' => '', 'comment' => '素材标题']) - ->addColumn('local_url', 'string', ['limit' => 500, 'default' => '', 'comment' => '素材链接']) - ->addColumn('show_cover_pic', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '显示封面(0隐藏,1显示)']) + ->addColumn('title', 'string', ['limit' => 50, 'default' => '', 'comment' => '素材标题']) + ->addColumn('local_url', 'string', ['limit' => 300, 'default' => '', 'comment' => '永久素材显示URL']) + ->addColumn('show_cover_pic', 'integer', ['limit' => 4, 'default' => 0, 'comment' => '显示封面(0不显示,1显示)']) ->addColumn('author', 'string', ['limit' => 20, 'default' => '', 'comment' => '文章作者']) ->addColumn('digest', 'string', ['limit' => 300, 'default' => '', 'comment' => '摘要内容']) - ->addColumn('content', 'text', ['default' => '', 'comment' => '图文内容']) + ->addColumn('content', 'text', ['default' => null, 'comment' => '图文内容']) ->addColumn('content_source_url', 'string', ['limit' => 200, 'default' => '', 'comment' => '原文地址']) ->addColumn('read_num', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '阅读数量']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) diff --git a/database/migrations/20221013045836_install_postage.php b/database/migrations/20221013045836_install_postage.php index a8cd024f5..ef1521550 100644 --- a/database/migrations/20221013045836_install_postage.php +++ b/database/migrations/20221013045836_install_postage.php @@ -15,11 +15,14 @@ class InstallPostage extends Migrator private function _company() { - // 当前操作 - $table = "base_postage_company"; + // 当前数据表 + $table = 'base_postage_company'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-快递-公司', ]) ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '快递公司名称']) @@ -28,11 +31,9 @@ class InstallPostage extends Migrator ->addColumn('code_3', 'string', ['limit' => 50, 'default' => '', 'comment' => '官方快递100代码']) ->addColumn('remark', 'string', ['limit' => 512, 'default' => '', 'comment' => '快递公司描述']) ->addColumn('sort', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '激活状态(0无效,1有效)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '删除状态(0未删,1已删)']) + ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态(0.无效,1.有效)']) + ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '删除状态(1已删除,0未删除)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) - ->addIndex('name', ['name' => 'idx_base_postage_company_name']) - ->addIndex('sort', ['name' => 'idx_base_postage_company_sort']) ->addIndex('code_1', ['name' => 'idx_base_postage_company_code_1']) ->addIndex('code_2', ['name' => 'idx_base_postage_company_code_2']) ->addIndex('code_3', ['name' => 'idx_base_postage_company_code_3']) @@ -43,8 +44,8 @@ class InstallPostage extends Migrator private function _region() { - // 当前操作 - $table = "base_postage_region"; + // 当前数据表 + $table = 'base_postage_region'; // 存在则跳过 if ($this->hasTable($table)) return; @@ -54,17 +55,17 @@ class InstallPostage extends Migrator 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-快递-区域', ]) ->addColumn('pid', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '上级PID']) - ->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('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' => '所在纬度']) ->addIndex('pid', ['name' => 'idx_base_postage_region_pid']) - ->addIndex('status', ['name' => 'idx_base_postage_region_status']) + ->addIndex('name', ['name' => 'idx_base_postage_region_name']) ->save(); // 写入默认区域数据 diff --git a/database/migrations/20221013045838_install_user.php b/database/migrations/20221013045838_install_user.php index f2eca107e..1ed72f0ab 100644 --- a/database/migrations/20221013045838_install_user.php +++ b/database/migrations/20221013045838_install_user.php @@ -188,11 +188,14 @@ class InstallUser extends Migrator private function _payment() { - // 当前操作 - $table = "data_user_payment"; + // 当前数据表 + $table = 'data_user_payment'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-用户-支付', ]) ->addColumn('order_no', 'string', ['limit' => 20, 'default' => '', 'comment' => '订单单号']) @@ -205,16 +208,24 @@ class InstallUser extends Migrator ->addColumn('payment_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'comment' => '支付金额']) ->addColumn('payment_datatime', 'string', ['limit' => 20, 'default' => '', 'comment' => '支付时间']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) + ->addIndex('order_no', ['name' => 'idx_data_user_payment_order_no']) + ->addIndex('payment_code', ['name' => 'idx_data_user_payment_payment_code']) + ->addIndex('payment_type', ['name' => 'idx_data_user_payment_payment_type']) + ->addIndex('payment_trade', ['name' => 'idx_data_user_payment_payment_trade']) + ->addIndex('payment_status', ['name' => 'idx_data_user_payment_payment_status']) ->save(); } private function _message() { - // 当前操作 - $table = "data_user_message"; + // 当前数据表 + $table = 'data_user_message'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-用户-短信', ]) ->addColumn('type', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '短信类型']) @@ -225,16 +236,24 @@ class InstallUser extends Migrator ->addColumn('content', 'string', ['limit' => 512, 'default' => '', 'comment' => '短信内容']) ->addColumn('status', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '短信状态(0失败,1成功)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) + ->addIndex('type', ['name' => 'idx_data_user_message_type']) + ->addIndex('status', ['name' => 'idx_data_user_message_status']) + ->addIndex('phone', ['name' => 'idx_data_user_message_phone']) + ->addIndex('msgid', ['name' => 'idx_data_user_message_msgid']) ->save(); + } private function _balance() { - // 当前操作 - $table = "data_user_balance"; + // 当前数据表 + $table = 'data_user_balance'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-用户-余额', ]) ->addColumn('uuid', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '用户UID']) @@ -246,17 +265,23 @@ class InstallUser extends Migrator ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '删除状态']) ->addColumn('create_by', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '系统用户']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) + ->addIndex('code', ['name' => 'idx_data_user_balance_code']) + ->addIndex('deleted', ['name' => 'idx_data_user_balance_deleted']) + ->addIndex('uuid', ['name' => 'idx_data_user_balance_uuid']) ->save(); } private function _address() { - // 当前操作 - $table = "data_user_address"; + // 当前数据表 + $table = 'data_user_address'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ - 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-用户-收货地址', + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-用户-地址', ]) ->addColumn('uuid', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '用户UID']) ->addColumn('type', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '地址类型(0普通,1默认)']) @@ -272,6 +297,10 @@ class InstallUser extends Migrator ->addColumn('address', 'string', ['limit' => 255, 'default' => '', 'comment' => '地址-详情']) ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '删除状态']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) + ->addIndex('code', ['name' => 'idx_data_user_address_code']) + ->addIndex('type', ['name' => 'idx_data_user_address_type']) + ->addIndex('uuid', ['name' => 'idx_data_user_address_uuid']) + ->addIndex('deleted', ['name' => 'idx_data_user_address_deleted']) ->save(); } } diff --git a/database/migrations/20221013075924_install_news.php b/database/migrations/20221013075924_install_news.php index e2700cfe1..931bd4f49 100644 --- a/database/migrations/20221013075924_install_news.php +++ b/database/migrations/20221013075924_install_news.php @@ -16,12 +16,16 @@ class InstallNews extends Migrator private function _collect() { - // 当前操作 - $table = "data_news_x_collect"; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ - 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-文章-交互', + // 当前数据表 + $table = 'data_news_x_collect'; + + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-文章-标记', ]) ->addColumn('uuid', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '用户UID']) ->addColumn('type', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '记录类型(1收藏,2点赞,3历史,4评论)']) @@ -29,16 +33,24 @@ class InstallNews extends Migrator ->addColumn('reply', 'text', ['default' => null, 'comment' => '评论内容']) ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '记录状态(0无效,1待审核,2已审核)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) + ->addIndex('type', ['name' => 'idx_data_news_x_collect_type']) + ->addIndex('code', ['name' => 'idx_data_news_x_collect_code']) + ->addIndex('status', ['name' => 'idx_data_news_x_collect_status']) + ->addIndex('uuid', ['name' => 'idx_data_news_x_collect_uuid']) ->save(); + } private function _mark() { - // 当前操作 - $table = "data_news_mark"; + // 当前数据表 + $table = 'data_news_mark'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-文章-标签', ]) ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'comment' => '标签名称']) @@ -47,17 +59,22 @@ class InstallNews extends Migrator ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '标签状态(1使用,0禁用)']) ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '删除状态']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) + ->addIndex('status', ['name' => 'idx_data_news_mark_status']) + ->addIndex('deleted', ['name' => 'idx_data_news_mark_deleted']) ->save(); } private function _news() { - // 当前操作 - $table = "data_news_item"; + // 当前数据表 + $table = 'data_news_item'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ - 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-文章', + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-文章-内容', ]) ->addColumn('code', 'string', ['limit' => 20, 'default' => '', 'comment' => '文章编号']) ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'comment' => '文章标题']) @@ -73,6 +90,9 @@ class InstallNews extends Migrator ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '文章状态(1使用,0禁用)']) ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '删除状态(0未删,1已删)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) + ->addIndex('status', ['name' => 'idx_data_news_item_status']) + ->addIndex('deleted', ['name' => 'idx_data_news_item_deleted']) + ->addIndex('code', ['name' => 'idx_data_news_item_code']) ->save(); } } diff --git a/database/migrations/20221013080600_install_shop.php b/database/migrations/20221013080600_install_shop.php index 26e516750..3b256ae48 100644 --- a/database/migrations/20221013080600_install_shop.php +++ b/database/migrations/20221013080600_install_shop.php @@ -21,12 +21,15 @@ class InstallShop extends Migrator private function _goods() { - // 当前操作 - $table = "shop_goods"; + // 当前数据表 + $table = 'shop_goods'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ - 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-主体', + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-内容', ]) ->addColumn('code', 'string', ['limit' => 20, 'default' => '', 'comment' => '商品编号']) ->addColumn('name', 'string', ['limit' => 500, 'default' => '', 'comment' => '商品名称']) @@ -60,8 +63,6 @@ class InstallShop extends Migrator ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '删除状态(0未删,1已删)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addIndex('code', ['name' => 'idx_shop_goods_code']) - ->addIndex('name', ['name' => 'idx_shop_goods_name']) - ->addIndex('sort', ['name' => 'idx_shop_goods_sort']) ->addIndex('status', ['name' => 'idx_shop_goods_status']) ->addIndex('deleted', ['name' => 'idx_shop_goods_deleted']) ->save(); @@ -69,11 +70,14 @@ class InstallShop extends Migrator private function _goodsCate() { - // 当前操作 - $table = "shop_goods_cate"; + // 当前数据表 + $table = 'shop_goods_cate'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-分类', ]) ->addColumn('pid', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '上级分类']) @@ -84,7 +88,6 @@ class InstallShop extends Migrator ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '使用状态']) ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '删除状态']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) - ->addIndex('pid', ['name' => 'idx_shop_goods_cate_pid']) ->addIndex('sort', ['name' => 'idx_shop_goods_cate_sort']) ->addIndex('status', ['name' => 'idx_shop_goods_cate_status']) ->addIndex('deleted', ['name' => 'idx_shop_goods_cate_deleted']) @@ -93,11 +96,14 @@ class InstallShop extends Migrator private function _goodsItems() { - // 当前操作 - $table = "shop_goods_item"; + // 当前数据表 + $table = 'shop_goods_item'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-规格', ]) ->addColumn('goods_sku', 'string', ['limit' => 20, 'default' => '', 'comment' => '商品SKU']) @@ -113,19 +119,22 @@ class InstallShop extends Migrator ->addColumn('reward_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'comment' => '奖励积分']) ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '商品状态']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) + ->addIndex('goods_code', ['name' => 'idx_shop_goods_item_goods_code']) + ->addIndex('goods_spec', ['name' => 'idx_shop_goods_item_goods_spec']) ->addIndex('status', ['name' => 'idx_shop_goods_item_status']) - ->addIndex('goods_code', ['name' => 'idx_shop_goods_item_gcode']) - ->addIndex('goods_spec', ['name' => 'idx_shop_goods_item_gspec']) ->save(); } private function _goodsMark() { - // 当前操作 - $table = "shop_goods_mark"; + // 当前数据表 + $table = 'shop_goods_mark'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-标签', ]) ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'comment' => '标签名称']) @@ -133,7 +142,6 @@ class InstallShop extends Migrator ->addColumn('sort', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '排序权重']) ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '标签状态(1使用,0禁用)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) - ->addIndex('name', ['name' => 'idx_shop_goods_mark_name']) ->addIndex('sort', ['name' => 'idx_shop_goods_mark_sort']) ->addIndex('status', ['name' => 'idx_shop_goods_mark_status']) ->save(); @@ -141,11 +149,14 @@ class InstallShop extends Migrator private function _goodsStock() { - // 当前操作 - $table = "shop_goods_stock"; + // 当前数据表 + $table = 'shop_goods_stock'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-库存', ]) ->addColumn('batch_no', 'string', ['limit' => 20, 'default' => '', 'comment' => '操作批量']) @@ -157,20 +168,20 @@ class InstallShop extends Migrator ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addIndex('status', ['name' => 'idx_shop_goods_stock_status']) ->addIndex('deleted', ['name' => 'idx_shop_goods_stock_deleted']) - ->addIndex('batch_no', ['name' => 'idx_shop_goods_stock_batch_no']) - ->addIndex('goods_code', ['name' => 'idx_shop_goods_stock_goods_code']) - ->addIndex('goods_spec', ['name' => 'idx_shop_goods_stock_goods_spec']) ->save(); } private function _order() { - // 当前操作 - $table = "shop_order"; + // 当前数据表 + $table = 'shop_order'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ - 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单', + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-内容', ]) ->addColumn('uuid', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '下单用户编号']) ->addColumn('puid1', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '推荐一层用户']) @@ -206,16 +217,27 @@ class InstallShop extends Migrator ->addColumn('deleted_datetime', 'string', ['limit' => 20, 'default' => '', 'comment' => '订单删除时间']) ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '订单流程状态(0已取消,1预订单,2待支付,3支付中,4已支付,5已发货,6已完成)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '订单创建时间']) + ->addIndex('uuid', ['name' => 'idx_shop_order_uuid']) + ->addIndex('puid1', ['name' => 'idx_shop_order_puid1']) + ->addIndex('status', ['name' => 'idx_shop_order_status']) + ->addIndex('order_no', ['name' => 'idx_shop_order_order_no']) + ->addIndex('cancel_status', ['name' => 'idx_shop_order_cancel_status']) + ->addIndex('payment_status', ['name' => 'idx_shop_order_payment_status']) + ->addIndex('deleted_status', ['name' => 'idx_shop_order_deleted_status']) ->save(); + } private function _orderItem() { - // 当前操作 - $table = "shop_order_item"; + // 当前数据表 + $table = 'shop_order_item'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-商品', ]) ->addColumn('uuid', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '商城用户编号']) @@ -248,17 +270,27 @@ class InstallShop extends Migrator ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '商品状态(1使用,0禁用)']) ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '删除状态(0未删,1已删)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '订单创建时间']) + ->addIndex('status', ['name' => 'idx_shop_order_item_status']) + ->addIndex('deleted', ['name' => 'idx_shop_order_item_deleted']) + ->addIndex('order_no', ['name' => 'idx_shop_order_item_order_no']) + ->addIndex('goods_sku', ['name' => 'idx_shop_order_item_goods_sku']) + ->addIndex('goods_code', ['name' => 'idx_shop_order_item_goods_code']) + ->addIndex('goods_spec', ['name' => 'idx_shop_order_item_goods_spec']) + ->addIndex('rebate_type', ['name' => 'idx_shop_order_item_rebate_type']) ->save(); } private function _orderSend() { - // 当前操作 - $table = "shop_order_send"; + // 当前数据表 + $table = 'shop_order_send'; - // 创建数据表,存在则跳过 - $this->hasTable($table) || $this->table($table, [ - 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-发货', + // 存在则跳过 + if ($this->hasTable($table)) return; + + // 创建数据表 + $this->table($table, [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-配送', ]) ->addColumn('uuid', 'integer', ['limit' => 20, 'default' => 0, 'comment' => '商城用户编号']) ->addColumn('order_no', 'string', ['limit' => 20, 'default' => '', 'comment' => '商城订单单号']) @@ -285,6 +317,10 @@ class InstallShop extends Migrator ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '发货商品状态(1使用,0禁用)']) ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '发货删除状态(0未删,1已删)']) ->addColumn('create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) + ->addIndex('uuid', ['name' => 'idx_shop_order_send_uuid']) + ->addIndex('status', ['name' => 'idx_shop_order_send_status']) + ->addIndex('deleted', ['name' => 'idx_shop_order_send_deleted']) + ->addIndex('order_no', ['name' => 'idx_shop_order_send_order_no']) ->save(); } }