From 491eb1e5397573c4284e27e81a456b3156162c7e Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Fri, 27 Aug 2021 23:50:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=86=E6=9E=B6=E5=8D=87=E7=BA=A72.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- app/Controller/Api/V1/ArticleController.php | 9 ++-- app/Service/ArticleService.php | 9 ++-- composer.json | 44 +++++++++---------- config/autoload/server.php | 18 ++++---- .../2020_11_04_152602_create_users_table.php | 6 +-- ...2020_11_04_153238_create_article_table.php | 10 ++--- ...1_04_153251_create_article_annex_table.php | 6 +-- ...1_04_153304_create_article_class_table.php | 10 ++--- ..._04_153316_create_article_detail_table.php | 11 +++-- ...11_04_153327_create_article_tags_table.php | 10 ++--- ...020_11_04_153337_create_emoticon_table.php | 5 +-- ...1_04_153347_create_emoticon_item_table.php | 5 +-- ..._153358_create_file_split_upload_table.php | 8 ++-- ...20_11_04_153421_create_talk_list_table.php | 5 +-- ...11_04_153431_create_talk_records_table.php | 5 +-- ..._153442_create_talk_records_file_table.php | 5 +-- ...53453_create_talk_records_delete_table.php | 5 +-- ...3504_create_talk_records_forward_table.php | 10 ++--- ...53516_create_talk_records_invite_table.php | 5 +-- ..._153529_create_talk_records_code_table.php | 6 +-- ..._04_153541_create_users_emoticon_table.php | 8 ++-- ...1_04_153553_create_users_friends_table.php | 5 +-- ...53605_create_users_friends_apply_table.php | 5 +-- .../2020_11_04_153616_create_group_table.php | 5 +-- ...11_04_153626_create_group_member_table.php | 5 +-- ...11_04_153636_create_group_notice_table.php | 5 +-- .../2021_07_02_165853_create_robots_table.php | 5 +-- ..._183045_create_talk_records_vote_table.php | 5 +-- ..._create_talk_records_vote_answer_table.php | 5 +-- ...183126_create_talk_records_login_table.php | 5 +-- 31 files changed, 91 insertions(+), 156 deletions(-) diff --git a/README.md b/README.md index f8ab720..08e0dfc 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Lumen-IM 是一个网页版在线即时聊天项目,前端使用 Element-ui + ## 3、环境要求 -- PHP >= 7.2 +- PHP >= 7.3 - MySQL >= 5.7 - Redis >= 5.0 - Swoole >= 4.5 diff --git a/app/Controller/Api/V1/ArticleController.php b/app/Controller/Api/V1/ArticleController.php index 2d73926..a822d95 100644 --- a/app/Controller/Api/V1/ArticleController.php +++ b/app/Controller/Api/V1/ArticleController.php @@ -43,9 +43,12 @@ class ArticleController extends CController */ public function getArticleClass() { - return $this->response->success([ - 'rows' => $this->articleService->getUserClass($this->uid()) - ]); + $rows = $this->articleService->getUserClass($this->uid()); + foreach ($rows as &$row) { + $row['count'] = is_null($row['count']) ? 0 : $row['count']; + } + + return $this->response->success(['rows' => $rows]); } /** diff --git a/app/Service/ArticleService.php b/app/Service/ArticleService.php index c17750b..43671bb 100644 --- a/app/Service/ArticleService.php +++ b/app/Service/ArticleService.php @@ -28,18 +28,17 @@ class ArticleService extends BaseService */ public function getUserClass(int $user_id) { - $subJoin = Article::select('class_id', Db::raw('count(class_id) as count'))->where('user_id', $user_id)->where('status', 1)->groupBy('class_id'); - $fields = [ 'article_class.id', 'article_class.class_name', 'article_class.is_default', - Db::raw('ifnull(sub_join.count,0) as count') + 'sub_join.count', ]; + $subJoin = Article::select(['class_id', Db::raw('count(class_id) as count')])->where('user_id', $user_id)->where('status', 1)->groupBy(['class_id']); return ArticleClass::leftJoinSub($subJoin, 'sub_join', function ($join) { - $join->on('article_class.id', '=', Db::raw('sub_join.class_id')); + $join->on('article_class.id', '=', 'sub_join.class_id'); })->where('article_class.user_id', $user_id) - ->orderBy('article_class.sort', 'asc') + ->orderBy('article_class.sort') ->get($fields) ->toArray(); } diff --git a/composer.json b/composer.json index a18a122..dc9611c 100644 --- a/composer.json +++ b/composer.json @@ -14,38 +14,38 @@ "require": { "php": ">=7.2", "ext-swoole": ">=4.5", - "hyperf/cache": "~2.0.0", - "hyperf/command": "~2.0.0", - "hyperf/config": "~2.0.0", - "hyperf/db-connection": "~2.0.0", - "hyperf/framework": "~2.0.0", - "hyperf/guzzle": "~2.0.0", - "hyperf/http-server": "~2.0.0", - "hyperf/logger": "~2.0.0", - "hyperf/memory": "~2.0.0", - "hyperf/process": "~2.0.0", - "hyperf/redis": "~2.0.0", - "hyperf/database": "~2.0.0", - "hyperf/async-queue": "~2.0.0", - "hyperf/websocket-server": "^2.0", - "hyperf/constants": "~2.0.0", - "hyperf/validation": "~2.0.0", - "hyperf/filesystem": "~2.0.0", + "hyperf/cache": "2.1.*", + "hyperf/command": "2.1.*", + "hyperf/config": "2.1.*", + "hyperf/db-connection": "2.1.*", + "hyperf/framework": "2.1.*", + "hyperf/guzzle": "2.1.*", + "hyperf/http-server": "2.1.*", + "hyperf/logger": "2.1.*", + "hyperf/memory": "2.1.*", + "hyperf/process": "2.1.*", + "hyperf/redis": "2.1.*", + "hyperf/database": "2.1.*", + "hyperf/async-queue": "2.1.*", + "hyperf/websocket-server": "2.1.*", + "hyperf/constants": "2.1.*", + "hyperf/validation": "2.1.*", + "hyperf/filesystem": "2.1.*", "hashids/hashids": "^4.0", "ext-json": "*", - "hyperf/view": "~2.0.0", - "hyperf/view-engine": "~2.0.0", + "hyperf/view": "2.1.*", + "hyperf/view-engine": "2.1.*", "phpmailer/phpmailer": "^6.2", "96qbhy/hyperf-auth": "^2.3", - "hyperf/event": "~2.0.0" + "hyperf/event": "2.1.*" }, "require-dev": { "swoole/ide-helper": "^4.5", "friendsofphp/php-cs-fixer": "^2.14", "mockery/mockery": "^1.0", "phpstan/phpstan": "^0.12", - "hyperf/devtool": "~2.0.0", - "hyperf/testing": "~2.0.0" + "hyperf/devtool": "2.1.*", + "hyperf/testing": "2.1.*" }, "suggest": { "ext-openssl": "Required to use HTTPS.", diff --git a/config/autoload/server.php b/config/autoload/server.php index 6a1555a..52c53ef 100644 --- a/config/autoload/server.php +++ b/config/autoload/server.php @@ -12,7 +12,7 @@ declare(strict_types=1); */ use Hyperf\Server\Server; -use Hyperf\Server\SwooleEvent; +use Hyperf\Server\Event; return [ 'mode' => SWOOLE_PROCESS, @@ -24,7 +24,7 @@ return [ 'port' => 9503, 'sock_type' => SWOOLE_SOCK_TCP, 'callbacks' => [ - SwooleEvent::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'], + Event::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'], ], ], [ @@ -35,9 +35,9 @@ return [ 'sock_type' => SWOOLE_SOCK_TCP, 'callbacks' => [ // 自定义握手处理 - SwooleEvent::ON_HAND_SHAKE => [Hyperf\WebSocketServer\Server::class, 'onHandShake'], - SwooleEvent::ON_MESSAGE => [Hyperf\WebSocketServer\Server::class, 'onMessage'], - SwooleEvent::ON_CLOSE => [Hyperf\WebSocketServer\Server::class, 'onClose'], + Event::ON_HAND_SHAKE => [Hyperf\WebSocketServer\Server::class, 'onHandShake'], + Event::ON_MESSAGE => [Hyperf\WebSocketServer\Server::class, 'onMessage'], + Event::ON_CLOSE => [Hyperf\WebSocketServer\Server::class, 'onClose'], ], 'settings' => [ // 设置心跳检测 @@ -60,9 +60,9 @@ return [ ], 'callbacks' => [ // 自定义启动前事件 - SwooleEvent::ON_BEFORE_START => [App\Bootstrap\ServerStart::class, 'beforeStart'], - SwooleEvent::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'], - SwooleEvent::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'], - SwooleEvent::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'], + Event::ON_BEFORE_START => [App\Bootstrap\ServerStart::class, 'beforeStart'], + Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'], + Event::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'], + Event::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'], ], ]; diff --git a/migrations/2020_11_04_152602_create_users_table.php b/migrations/2020_11_04_152602_create_users_table.php index 0571af0..37c952a 100644 --- a/migrations/2020_11_04_152602_create_users_table.php +++ b/migrations/2020_11_04_152602_create_users_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateUsersTable extends Migration { @@ -30,10 +29,9 @@ class CreateUsersTable extends Migration $table->engine = 'InnoDB'; $table->unique(['mobile'], 'uk_mobile'); - }); - $prefix = config('databases.default.prefix'); - Db::statement("ALTER TABLE `{$prefix}users` comment '用户信息表'"); + $table->comment('用户信息表'); + }); } /** diff --git a/migrations/2020_11_04_153238_create_article_table.php b/migrations/2020_11_04_153238_create_article_table.php index 8756d01..47dff89 100644 --- a/migrations/2020_11_04_153238_create_article_table.php +++ b/migrations/2020_11_04_153238_create_article_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateArticleTable extends Migration { @@ -26,16 +25,15 @@ class CreateArticleTable extends Migration $table->dateTime('updated_at')->nullable(true)->comment('最后一次更新时间'); $table->dateTime('deleted_at')->nullable(true)->comment('笔记删除时间'); - $table->charset = 'utf8'; + $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; - $table->engine = 'InnoDB'; + $table->engine = 'InnoDB'; //创建索引 $table->index(['user_id', 'class_id', 'title'], 'idx_user_id_class_id_title'); - }); - $prefix = config('databases.default.prefix'); - Db::statement("ALTER TABLE `{$prefix}article` comment '用户笔记表'"); + $table->comment('用户笔记表'); + }); } /** diff --git a/migrations/2020_11_04_153251_create_article_annex_table.php b/migrations/2020_11_04_153251_create_article_annex_table.php index 3ce57b4..9a47088 100644 --- a/migrations/2020_11_04_153251_create_article_annex_table.php +++ b/migrations/2020_11_04_153251_create_article_annex_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateArticleAnnexTable extends Migration { @@ -29,10 +28,9 @@ class CreateArticleAnnexTable extends Migration $table->engine = 'InnoDB'; $table->index(['user_id', 'article_id'], 'idx_user_id_article_id'); - }); - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}article_annex` comment '笔记附件信息表'"); + $table->comment('笔记附件信息表'); + }); } /** diff --git a/migrations/2020_11_04_153304_create_article_class_table.php b/migrations/2020_11_04_153304_create_article_class_table.php index 5a1a0fe..5b62c89 100644 --- a/migrations/2020_11_04_153304_create_article_class_table.php +++ b/migrations/2020_11_04_153304_create_article_class_table.php @@ -3,7 +3,7 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; + class CreateArticleClassTable extends Migration { /** @@ -19,15 +19,13 @@ class CreateArticleClassTable extends Migration $table->unsignedTinyInteger('is_default')->default(0)->comment('默认分类[1:是;0:不是]'); $table->unsignedInteger('created_at')->nullable(true)->default(0)->comment('创建时间'); - $table->charset = 'utf8'; + $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; - $table->engine = 'InnoDB'; + $table->engine = 'InnoDB'; $table->index(['user_id', 'sort'], 'idx_user_id_sort'); + $table->comment('笔记分类表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}article_class` comment '笔记分类表'"); } /** diff --git a/migrations/2020_11_04_153316_create_article_detail_table.php b/migrations/2020_11_04_153316_create_article_detail_table.php index 7ce9f4a..d301deb 100644 --- a/migrations/2020_11_04_153316_create_article_detail_table.php +++ b/migrations/2020_11_04_153316_create_article_detail_table.php @@ -3,7 +3,7 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; + class CreateArticleDetailTable extends Migration { /** @@ -17,15 +17,14 @@ class CreateArticleDetailTable extends Migration $table->longtext('md_content')->charset('utf8mb4')->comment('Markdown 内容'); $table->longtext('content')->charset('utf8mb4')->comment('Markdown 解析HTML内容'); - $table->charset = 'utf8'; + $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; - $table->engine = 'InnoDB'; + $table->engine = 'InnoDB'; $table->unique('article_id', 'unique_article_id'); - }); - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}article_detail` comment '笔记详情表'"); + $table->comment('笔记详情表'); + }); } /** diff --git a/migrations/2020_11_04_153327_create_article_tags_table.php b/migrations/2020_11_04_153327_create_article_tags_table.php index 1213e3c..8a8e330 100644 --- a/migrations/2020_11_04_153327_create_article_tags_table.php +++ b/migrations/2020_11_04_153327_create_article_tags_table.php @@ -3,7 +3,7 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; + class CreateArticleTagsTable extends Migration { /** @@ -18,14 +18,12 @@ class CreateArticleTagsTable extends Migration $table->unsignedTinyInteger('sort')->default(0)->comment('排序'); $table->unsignedInteger('created_at')->nullable(true)->default(0)->comment('创建时间'); - $table->charset = 'utf8'; + $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; - $table->engine = 'InnoDB'; + $table->engine = 'InnoDB'; $table->index(['user_id'], 'idx_user_id'); + $table->comment('笔记标签表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}article_tags` comment '笔记标签表'"); } /** diff --git a/migrations/2020_11_04_153337_create_emoticon_table.php b/migrations/2020_11_04_153337_create_emoticon_table.php index 27f406e..a9c4b23 100644 --- a/migrations/2020_11_04_153337_create_emoticon_table.php +++ b/migrations/2020_11_04_153337_create_emoticon_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateEmoticonTable extends Migration { @@ -24,10 +23,8 @@ class CreateEmoticonTable extends Migration $table->collation = 'utf8_general_ci'; $table->unique(['name'], 'uk_name'); + $table->comment('表情包'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}emoticon` comment '表情包'"); } /** diff --git a/migrations/2020_11_04_153347_create_emoticon_item_table.php b/migrations/2020_11_04_153347_create_emoticon_item_table.php index d69250f..71a8a94 100644 --- a/migrations/2020_11_04_153347_create_emoticon_item_table.php +++ b/migrations/2020_11_04_153347_create_emoticon_item_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateEmoticonItemTable extends Migration { @@ -25,10 +24,8 @@ class CreateEmoticonItemTable extends Migration $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; + $table->comment('表情包详情表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}emoticon_item` comment '表情包详情表'"); } /** diff --git a/migrations/2020_11_04_153358_create_file_split_upload_table.php b/migrations/2020_11_04_153358_create_file_split_upload_table.php index ce98cd1..ef1a3c1 100644 --- a/migrations/2020_11_04_153358_create_file_split_upload_table.php +++ b/migrations/2020_11_04_153358_create_file_split_upload_table.php @@ -3,7 +3,7 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; + class CreateFileSplitUploadTable extends Migration { /** @@ -25,14 +25,12 @@ class CreateFileSplitUploadTable extends Migration $table->unsignedTinyInteger('is_delete')->default(0)->comment('文件是否已被删除[0:否;1:是]'); $table->unsignedInteger('upload_at')->nullable(true)->comment('文件上传时间'); - $table->charset = 'utf8'; + $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; $table->index(['user_id', 'hash_name'], 'idx_user_id_hash_name'); + $table->comment('文件拆分上传'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}file_split_upload` comment '文件拆分上传'"); } /** diff --git a/migrations/2020_11_04_153421_create_talk_list_table.php b/migrations/2020_11_04_153421_create_talk_list_table.php index 8a06a52..2f063be 100644 --- a/migrations/2020_11_04_153421_create_talk_list_table.php +++ b/migrations/2020_11_04_153421_create_talk_list_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateTalkListTable extends Migration { @@ -29,10 +28,8 @@ class CreateTalkListTable extends Migration $table->engine = 'InnoDB'; $table->index(['user_id', 'receiver_id', 'talk_type'], 'idx_user_id_receiver_id_talk_type'); + $table->comment('用户聊天列表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}talk_list` comment '用户聊天列表'"); } /** diff --git a/migrations/2020_11_04_153431_create_talk_records_table.php b/migrations/2020_11_04_153431_create_talk_records_table.php index 9777489..d72c41e 100644 --- a/migrations/2020_11_04_153431_create_talk_records_table.php +++ b/migrations/2020_11_04_153431_create_talk_records_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateTalkRecordsTable extends Migration { @@ -32,10 +31,8 @@ class CreateTalkRecordsTable extends Migration $table->engine = 'InnoDB'; $table->index(['user_id', 'receiver_id'], 'idx_user_id_receiver_id'); + $table->comment('用户聊天记录表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}talk_records` comment '用户聊天记录表'"); } /** diff --git a/migrations/2020_11_04_153442_create_talk_records_file_table.php b/migrations/2020_11_04_153442_create_talk_records_file_table.php index 4cae5b9..7e2a162 100644 --- a/migrations/2020_11_04_153442_create_talk_records_file_table.php +++ b/migrations/2020_11_04_153442_create_talk_records_file_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateTalkRecordsFileTable extends Migration { @@ -31,10 +30,8 @@ class CreateTalkRecordsFileTable extends Migration $table->engine = 'InnoDB'; $table->unique(['record_id'], 'uk_record_id'); + $table->comment('用户聊天记录_文件消息表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}talk_records_file` comment '用户聊天记录_文件消息表'"); } /** diff --git a/migrations/2020_11_04_153453_create_talk_records_delete_table.php b/migrations/2020_11_04_153453_create_talk_records_delete_table.php index eaeb4ab..8bdaed6 100644 --- a/migrations/2020_11_04_153453_create_talk_records_delete_table.php +++ b/migrations/2020_11_04_153453_create_talk_records_delete_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateTalkRecordsDeleteTable extends Migration { @@ -23,10 +22,8 @@ class CreateTalkRecordsDeleteTable extends Migration $table->engine = 'InnoDB'; $table->unique(['record_id', 'user_id'], 'uk_record_id_user_id'); + $table->comment('用户聊天记录_删除记录表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}talk_records_delete` comment '用户聊天记录_删除记录表'"); } /** diff --git a/migrations/2020_11_04_153504_create_talk_records_forward_table.php b/migrations/2020_11_04_153504_create_talk_records_forward_table.php index 0946244..723787d 100644 --- a/migrations/2020_11_04_153504_create_talk_records_forward_table.php +++ b/migrations/2020_11_04_153504_create_talk_records_forward_table.php @@ -3,7 +3,7 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; + class CreateTalkRecordsForwardTable extends Migration { /** @@ -19,15 +19,13 @@ class CreateTalkRecordsForwardTable extends Migration $table->json('text')->default(null)->comment('记录快照'); $table->dateTime('created_at')->nullable(true)->comment('转发时间'); - $table->charset = 'utf8'; + $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; - $table->engine = 'InnoDB'; + $table->engine = 'InnoDB'; $table->index(['user_id', 'records_id'], 'idx_user_id_records_id'); + $table->comment('用户聊天记录_转发信息表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}talk_records_forward` comment '用户聊天记录_转发信息表'"); } /** diff --git a/migrations/2020_11_04_153516_create_talk_records_invite_table.php b/migrations/2020_11_04_153516_create_talk_records_invite_table.php index 27e4f5c..eae72e7 100644 --- a/migrations/2020_11_04_153516_create_talk_records_invite_table.php +++ b/migrations/2020_11_04_153516_create_talk_records_invite_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateTalkRecordsInviteTable extends Migration { @@ -24,10 +23,8 @@ class CreateTalkRecordsInviteTable extends Migration $table->engine = 'InnoDB'; $table->index(['record_id'], 'idx_record_id'); + $table->comment('用户聊天记录_入群或退群消息表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}talk_records_invite` comment '用户聊天记录_入群或退群消息表'"); } /** diff --git a/migrations/2020_11_04_153529_create_talk_records_code_table.php b/migrations/2020_11_04_153529_create_talk_records_code_table.php index e76fe00..3dcc07f 100644 --- a/migrations/2020_11_04_153529_create_talk_records_code_table.php +++ b/migrations/2020_11_04_153529_create_talk_records_code_table.php @@ -24,11 +24,9 @@ class CreateTalkRecordsCodeTable extends Migration $table->collation = 'utf8_general_ci'; $table->engine = 'InnoDB'; - $table->index(['record_id'], 'idx_recordid'); + $table->index(['record_id'], 'idx_record_id'); + $table->comment('用户聊天记录_代码块消息表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}talk_records_code` comment '用户聊天记录_代码块消息表'"); } /** diff --git a/migrations/2020_11_04_153541_create_users_emoticon_table.php b/migrations/2020_11_04_153541_create_users_emoticon_table.php index bfbef38..7ddd6d1 100644 --- a/migrations/2020_11_04_153541_create_users_emoticon_table.php +++ b/migrations/2020_11_04_153541_create_users_emoticon_table.php @@ -3,7 +3,7 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; + class CreateUsersEmoticonTable extends Migration { /** @@ -16,14 +16,12 @@ class CreateUsersEmoticonTable extends Migration $table->unsignedInteger('user_id')->default(0)->comment('用户ID'); $table->string('emoticon_ids', 255)->default('')->comment('表情包ID'); - $table->charset = 'utf8'; + $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; $table->unique(['user_id'], 'uk_user_id'); + $table->comment('用户收藏表情包'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}users_emoticon` comment '用户收藏表情包'"); } /** diff --git a/migrations/2020_11_04_153553_create_users_friends_table.php b/migrations/2020_11_04_153553_create_users_friends_table.php index de152e1..f44adf6 100644 --- a/migrations/2020_11_04_153553_create_users_friends_table.php +++ b/migrations/2020_11_04_153553_create_users_friends_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateUsersFriendsTable extends Migration { @@ -26,10 +25,8 @@ class CreateUsersFriendsTable extends Migration $table->engine = 'InnoDB'; $table->index(['user_id', 'friend_id'], 'idx_user_id_friend_id'); + $table->comment('用户好友关系表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}users_friends` comment '用户好友关系表'"); } /** diff --git a/migrations/2020_11_04_153605_create_users_friends_apply_table.php b/migrations/2020_11_04_153605_create_users_friends_apply_table.php index 2b48dcd..aa4c61e 100644 --- a/migrations/2020_11_04_153605_create_users_friends_apply_table.php +++ b/migrations/2020_11_04_153605_create_users_friends_apply_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateUsersFriendsApplyTable extends Migration { @@ -25,10 +24,8 @@ class CreateUsersFriendsApplyTable extends Migration $table->index(['user_id'], 'idx_user_id'); $table->index(['friend_id'], 'idx_friend_id'); + $table->comment('用户添加好友申请表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}users_friends_apply` comment '用户添加好友申请表'"); } /** diff --git a/migrations/2020_11_04_153616_create_group_table.php b/migrations/2020_11_04_153616_create_group_table.php index 08c0967..9773dca 100644 --- a/migrations/2020_11_04_153616_create_group_table.php +++ b/migrations/2020_11_04_153616_create_group_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateGroupTable extends Migration { @@ -28,10 +27,8 @@ class CreateGroupTable extends Migration $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; $table->engine = 'InnoDB'; + $table->comment('聊天群组表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}group` comment '聊天群组表'"); } /** diff --git a/migrations/2020_11_04_153626_create_group_member_table.php b/migrations/2020_11_04_153626_create_group_member_table.php index 6a33b83..964e3f9 100644 --- a/migrations/2020_11_04_153626_create_group_member_table.php +++ b/migrations/2020_11_04_153626_create_group_member_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateGroupMemberTable extends Migration { @@ -29,10 +28,8 @@ class CreateGroupMemberTable extends Migration $table->unique(['group_id', 'user_id'], 'uk_group_id_user_id'); $table->index(['user_id'], 'idx_user_id'); + $table->comment('聊天群组成员表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}group_member` comment '聊天群组成员表'"); } /** diff --git a/migrations/2020_11_04_153636_create_group_notice_table.php b/migrations/2020_11_04_153636_create_group_notice_table.php index 2f7442a..9ba9cb7 100644 --- a/migrations/2020_11_04_153636_create_group_notice_table.php +++ b/migrations/2020_11_04_153636_create_group_notice_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateGroupNoticeTable extends Migration { @@ -31,10 +30,8 @@ class CreateGroupNoticeTable extends Migration $table->engine = 'InnoDB'; $table->index(['group_id', 'is_delete', 'is_top', 'updated_at'], 'idx_group_id_is_delete_is_top_updated_at'); + $table->comment('群组公告表'); }); - - $prefix = config('databases.default.prefix'); - DB::statement("ALTER TABLE `{$prefix}group_notice` comment '群组公告表'"); } /** diff --git a/migrations/2021_07_02_165853_create_robots_table.php b/migrations/2021_07_02_165853_create_robots_table.php index f91dff7..54b610e 100644 --- a/migrations/2021_07_02_165853_create_robots_table.php +++ b/migrations/2021_07_02_165853_create_robots_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateRobotsTable extends Migration { @@ -26,10 +25,8 @@ class CreateRobotsTable extends Migration $table->charset = 'utf8'; $table->collation = 'utf8_general_ci'; $table->engine = 'InnoDB'; + $table->comment('聊天机器人表'); }); - - $prefix = config('databases.default.prefix'); - Db::statement("ALTER TABLE `{$prefix}robots` comment '聊天机器人表'"); } /** diff --git a/migrations/2021_08_01_183045_create_talk_records_vote_table.php b/migrations/2021_08_01_183045_create_talk_records_vote_table.php index 3b990f8..7f6c485 100644 --- a/migrations/2021_08_01_183045_create_talk_records_vote_table.php +++ b/migrations/2021_08_01_183045_create_talk_records_vote_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateTalkRecordsVoteTable extends Migration { @@ -30,10 +29,8 @@ class CreateTalkRecordsVoteTable extends Migration $table->engine = 'InnoDB'; $table->unique(['record_id'], 'uk_record_id'); + $table->comment('聊天对话记录(投票消息表)'); }); - - $prefix = config('databases.default.prefix'); - Db::statement("ALTER TABLE `{$prefix}talk_records_vote` comment '聊天对话记录(投票消息表)'"); } /** diff --git a/migrations/2021_08_01_183108_create_talk_records_vote_answer_table.php b/migrations/2021_08_01_183108_create_talk_records_vote_answer_table.php index 0c0c0cf..69ac62c 100644 --- a/migrations/2021_08_01_183108_create_talk_records_vote_answer_table.php +++ b/migrations/2021_08_01_183108_create_talk_records_vote_answer_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateTalkRecordsVoteAnswerTable extends Migration { @@ -24,10 +23,8 @@ class CreateTalkRecordsVoteAnswerTable extends Migration $table->engine = 'InnoDB'; $table->index(['vote_id', 'user_id'], 'idx_vote_id_user_id'); + $table->comment('聊天对话记录(投票消息统计表)'); }); - - $prefix = config('databases.default.prefix'); - Db::statement("ALTER TABLE `{$prefix}talk_records_vote_answer` comment '聊天对话记录(投票消息统计表)'"); } /** diff --git a/migrations/2021_08_01_183126_create_talk_records_login_table.php b/migrations/2021_08_01_183126_create_talk_records_login_table.php index 79a9845..f1c9172 100644 --- a/migrations/2021_08_01_183126_create_talk_records_login_table.php +++ b/migrations/2021_08_01_183126_create_talk_records_login_table.php @@ -3,7 +3,6 @@ use Hyperf\Database\Schema\Schema; use Hyperf\Database\Schema\Blueprint; use Hyperf\Database\Migrations\Migration; -use Hyperf\DbConnection\Db; class CreateTalkRecordsLoginTable extends Migration { @@ -28,10 +27,8 @@ class CreateTalkRecordsLoginTable extends Migration $table->engine = 'InnoDB'; $table->unique(['record_id'], 'uk_record_id'); + $table->comment('聊天对话记录(登录日志)'); }); - - $prefix = config('databases.default.prefix'); - Db::statement("ALTER TABLE `{$prefix}talk_records_login` comment '聊天对话记录(登录日志)'"); } /**