Browse Source

perf: add more index to tables

M1Screw 1 năm trước cách đây
mục cha
commit
a923823788

+ 4 - 2
README.md

@@ -24,7 +24,7 @@
 
 ## 简介 / TL;DR
 
-SSPanel UIM 是一款专为 Shadowsocks / V2Ray / Trojan / TUIC 协议设计的多用途代理服务销售管理系统。  
+SSPanel UIM 是一款专为 Shadowsocks(包括 2022 Edition) / V2Ray / Trojan / TUIC 协议设计的多用途代理服务销售管理系统。  
 SSPanel UIM is a multi-purpose proxy service sales management system designed for Shadowsocks / V2Ray / Trojan / TUIC protocol.
 
 ## 特性 / Features
@@ -33,7 +33,7 @@ SSPanel UIM is a multi-purpose proxy service sales management system designed fo
 - 支持多种邮件服务,内置邮件队列功能,无需第三方组件即可使用
 - 内置基于 Bootstrap 5 的 tabler 主题,模板引擎支持
 - 支持 Shadowsocks 2022,TUIC 等最新代理协议
-- 通用订阅接口,一键 json/clash/sip008/sing-box 格式订阅下发
+- 通用订阅接口,一键 json/clash/sip008/sing-box/v2ray-json 格式订阅下发
 - 自定义节点配置,模块化订阅系统,支持多种客户端专用订阅格式
 - 重构的商店系统,支持包括但不限于包年包月,按量计费,接入类型计费等计费模式
 - 重构的定时任务系统,一个命令即可自动完成所有定时任务
@@ -41,6 +41,7 @@ SSPanel UIM is a multi-purpose proxy service sales management system designed fo
 - 一键对接 OpenAI,Gemini Pro,Hugging Face Hosted API 和 Cloudflare Workers AI 等人工智能服务
 
 
+
 - Integrate multiple payment systems such as Alipay F2F, PayPal, Stripe, etc.
 - Support multiple mail services, built-in mail queue function, no third-party components are required to use
 - Built-in tabler theme based on Bootstrap 5, template engine support
@@ -50,6 +51,7 @@ SSPanel UIM is a multi-purpose proxy service sales management system designed fo
 - Refactored store system, support billing modes including but not limited to annual/monthly, pay-as-you-go, access type billing, etc.
 - Refactored scheduled task system, one command can automatically complete all scheduled tasks
 - Deep integration of large language models, support intelligent reply to ticket, document generation and other functions
+- One-click access to OpenAI, Gemini Pro, Hugging Face Hosted API, Cloudflare Workers AI and other artificial intelligence services
 
 ## 安装 / Installation
 

+ 6 - 6
composer.lock

@@ -656,16 +656,16 @@
         },
         {
             "name": "doctrine/inflector",
-            "version": "2.0.9",
+            "version": "2.0.10",
             "source": {
                 "type": "git",
                 "url": "https://github.com/doctrine/inflector.git",
-                "reference": "2930cd5ef353871c821d5c43ed030d39ac8cfe65"
+                "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/doctrine/inflector/zipball/2930cd5ef353871c821d5c43ed030d39ac8cfe65",
-                "reference": "2930cd5ef353871c821d5c43ed030d39ac8cfe65",
+                "url": "https://api.github.com/repos/doctrine/inflector/zipball/5817d0659c5b50c9b950feb9af7b9668e2c436bc",
+                "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc",
                 "shasum": ""
             },
             "require": {
@@ -727,7 +727,7 @@
             ],
             "support": {
                 "issues": "https://github.com/doctrine/inflector/issues",
-                "source": "https://github.com/doctrine/inflector/tree/2.0.9"
+                "source": "https://github.com/doctrine/inflector/tree/2.0.10"
             },
             "funding": [
                 {
@@ -743,7 +743,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-01-15T18:05:13+00:00"
+            "time": "2024-02-18T20:23:39+00:00"
         },
         {
             "name": "endroid/qr-code",

+ 26 - 9
db/migrations/2023020100-init.php

@@ -25,7 +25,10 @@ return new class() implements MigrationInterface {
                 `type` varchar(255) DEFAULT NULL COMMENT '配置值类型',
                 `default` varchar(255) DEFAULT NULL COMMENT '默认值',
                 `mark` varchar(255) DEFAULT NULL COMMENT '备注',
-                PRIMARY KEY (`id`)
+                PRIMARY KEY (`id`),
+                KEY `item` (`item`),
+                KEY `class` (`class`),
+                KEY `is_public` (`is_public`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
             CREATE TABLE `detect_ban_log` (
@@ -99,7 +102,8 @@ return new class() implements MigrationInterface {
                 `date` date NOT NULL DEFAULT 0 COMMENT '记录日期',
                 `usage` longtext NOT NULL DEFAULT '{}' COMMENT '流量用量' CHECK (json_valid(`usage`)),
                 PRIMARY KEY (`id`),
-                KEY `user_id` (`user_id`)
+                KEY `user_id` (`user_id`),
+                KEY `date` (`date`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
             CREATE TABLE `invoice` (
@@ -163,9 +167,12 @@ return new class() implements MigrationInterface {
                 `gfw_block` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否被GFW封锁',
                 `password` varchar(255) NOT NULL DEFAULT '' COMMENT '后端连接密码',
                 PRIMARY KEY (`id`),
+                UNIQUE KEY `password` (`password`),
                 KEY `type` (`type`),
                 KEY `sort` (`sort`),
+                KEY `is_dynamic_rate` (`is_dynamic_rate`),
                 KEY `node_class` (`node_class`),
+                KEY `bandwidthlimit_resetday` (`bandwidthlimit_resetday`),
                 KEY `node_group` (`node_group`),
                 KEY `online` (`online`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
@@ -179,7 +186,8 @@ return new class() implements MigrationInterface {
                 `last_time` int(11) unsigned NOT NULL COMMENT '最后在线时间',
                 PRIMARY KEY (`id`),
                 UNIQUE KEY (`user_id`, `ip`),
-                KEY (`last_time`)
+                KEY `node_id` (`node_id`),
+                KEY `last_time` (`last_time`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
             CREATE TABLE `order` (
@@ -209,7 +217,10 @@ return new class() implements MigrationInterface {
                 `ref_get` decimal(12,2) unsigned NOT NULL DEFAULT 0 COMMENT '推荐人获得金额',
                 `invoice_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账单ID',
                 `datetime` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
-                PRIMARY KEY (`id`)
+                PRIMARY KEY (`id`),
+                KEY `userid` (`userid`),
+                KEY `ref_by` (`ref_by`),
+                KEY `invoice_id` (`invoice_id`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
             CREATE TABLE `paylist` (
@@ -222,7 +233,10 @@ return new class() implements MigrationInterface {
                 `gateway` varchar(255) NOT NULL DEFAULT '' COMMENT '支付网关',
                 `datetime` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
                 PRIMARY KEY (`id`),
-                KEY `userid` (`userid`)
+                UNIQUE KEY `tradeno` (`tradeno`),
+                KEY `userid` (`userid`),
+                KEY `status` (`status`),
+                KEY `invoice_id` (`invoice_id`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
             CREATE TABLE `product` (
@@ -251,7 +265,8 @@ return new class() implements MigrationInterface {
                 `request_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '请求时间',
                 `request_user_agent` varchar(255) NOT NULL DEFAULT '' COMMENT '请求UA',
                 PRIMARY KEY (`id`),
-                KEY `user_id` (`user_id`)
+                KEY `user_id` (`user_id`),
+                KEY `type` (`type`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
             CREATE TABLE `ticket` (
@@ -259,12 +274,13 @@ return new class() implements MigrationInterface {
                 `title` varchar(255) NOT NULL DEFAULT '' COMMENT '工单标题',
                 `content` longtext NOT NULL DEFAULT '{}' COMMENT '工单内容' CHECK (json_valid(`content`)),
                 `userid` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
-                `datetime` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
                 `status` varchar(255) NOT NULL DEFAULT '' COMMENT '工单状态',
                 `type` varchar(255) NOT NULL DEFAULT '' COMMENT '工单类型',
+                `datetime` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
                 PRIMARY KEY (`id`),
                 KEY `userid` (`userid`),
-                KEY `status` (`status`)
+                KEY `status` (`status`),
+                KEY `type` (`type`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
             CREATE TABLE `user` (
@@ -318,12 +334,13 @@ return new class() implements MigrationInterface {
                 `is_inactive` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否处于闲置状态',
                 `locale` varchar(16) NOT NULL DEFAULT 'zh-TW' COMMENT '显示语言',
                 PRIMARY KEY (`id`),
-                UNIQUE KEY `uuid` (`uuid`),
                 UNIQUE KEY `email` (`email`),
+                UNIQUE KEY `uuid` (`uuid`),
                 UNIQUE KEY `ga_token` (`ga_token`),
                 UNIQUE KEY `api_token` (`api_token`),
                 KEY `is_admin` (`is_admin`),
                 KEY `is_banned` (`is_banned`),
+                KEY `is_shadow_banned` (`is_shadow_banned`),
                 KEY `is_inactive` (`is_inactive`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 

+ 37 - 0
db/migrations/2024021900-add_missing_indexes.php

@@ -0,0 +1,37 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Interfaces\MigrationInterface;
+use App\Services\DB;
+
+return new class() implements MigrationInterface {
+    public function up(): int
+    {
+        DB::getPdo()->exec('
+        ALTER TABLE config ADD KEY IF NOT EXISTS `item` (`item`);
+        ALTER TABLE config ADD KEY IF NOT EXISTS `class` (`class`);
+        ALTER TABLE config ADD KEY IF NOT EXISTS `is_public` (`is_public`);
+        ALTER TABLE hourly_usage ADD KEY IF NOT EXISTS `date` (`date`);
+        ALTER TABLE node ADD UNIQUE KEY IF NOT EXISTS `password` (`password`);
+        ALTER TABLE node ADD KEY IF NOT EXISTS `is_dynamic_rate` (`is_dynamic_rate`);
+        ALTER TABLE node ADD KEY IF NOT EXISTS `bandwidthlimit_resetday` (`bandwidthlimit_resetday`);
+        ALTER TABLE online_log ADD KEY IF NOT EXISTS `node_id` (`node_id`);
+        ALTER TABLE payback ADD KEY IF NOT EXISTS `userid` (`userid`);
+        ALTER TABLE payback ADD KEY IF NOT EXISTS `ref_by` (`ref_by`);
+        ALTER TABLE payback ADD KEY IF NOT EXISTS `invoice_id` (`invoice_id`);
+        ALTER TABLE paylist ADD UNIQUE KEY IF NOT EXISTS `tradeno` (`tradeno`);
+        ALTER TABLE paylist ADD KEY IF NOT EXISTS `status` (`status`);
+        ALTER TABLE paylist ADD KEY IF NOT EXISTS `invoice_id` (`invoice_id`);
+        ALTER TABLE subscribe_log ADD KEY IF NOT EXISTS `type` (`type`);
+        ALTER TABLE ticket ADD KEY IF NOT EXISTS `type` (`type`);
+        ALTER TABLE user ADD KEY IF NOT EXISTS `is_shadow_banned` (`is_shadow_banned`);');
+
+        return 2024021900;
+    }
+
+    public function down(): int
+    {
+        return 2024012700;
+    }
+};