/*
 Navicat Premium Dump SQL

 Source Server         : 亿速云（国内）
 Source Server Type    : MySQL
 Source Server Version : 80018 (8.0.18)
 Source Host           : yisurds-66dc0b453c05d4.rds.ysydb1.com:14080
 Source Schema         : LMS_TEST

 Target Server Type    : MySQL
 Target Server Version : 80018 (8.0.18)
 File Encoding         : 65001

 Date: 13/10/2024 21:05:08
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for ApiEndpoints
-- ----------------------------
CREATE TABLE IF NOT EXISTS `ApiEndpoints`  (
  `Id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `HttpMethod` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'Http请求方式',
  `Path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'Http请求地址',
  `CreateTime` datetime NOT NULL COMMENT '创建时间',
  `RequiredPermissionIds` json NOT NULL COMMENT '需要的权限ID',
  `CreatedId` bigint(20) NOT NULL COMMENT '创建者ID',
  `UpdatedId` bigint(20) NOT NULL COMMENT '更新者ID',
  PRIMARY KEY (`Id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for AspNetRoleClaims
-- ----------------------------
CREATE TABLE IF NOT EXISTS `AspNetRoleClaims`  (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `RoleId` bigint(20) NOT NULL,
  `ClaimType` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  `ClaimValue` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  PRIMARY KEY (`Id`) USING BTREE,
  INDEX `IX_AspNetRoleClaims_RoleId`(`RoleId` ASC) USING BTREE,
  CONSTRAINT `FK_AspNetRoleClaims_AspNetRoles_RoleId` FOREIGN KEY (`RoleId`) REFERENCES `AspNetRoles` (`Id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for AspNetRoles
-- ----------------------------
CREATE TABLE IF NOT EXISTS `AspNetRoles`  (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `Name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `NormalizedName` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `ConcurrencyStamp` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  `CreatedUserId` bigint(20) NOT NULL,
  `UpdatedUserId` bigint(20) NOT NULL,
  `CreatedTime` datetime NOT NULL,
  `UpdatedTime` datetime NOT NULL,
  `Remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  PRIMARY KEY (`Id`) USING BTREE,
  UNIQUE INDEX `RoleNameIndex`(`NormalizedName` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for AspNetUserClaims
-- ----------------------------
CREATE TABLE IF NOT EXISTS `AspNetUserClaims`  (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `UserId` bigint(20) NOT NULL,
  `ClaimType` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  `ClaimValue` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  PRIMARY KEY (`Id`) USING BTREE,
  INDEX `IX_AspNetUserClaims_UserId`(`UserId` ASC) USING BTREE,
  CONSTRAINT `FK_AspNetUserClaims_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `AspNetUsers` (`Id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for AspNetUserLogins
-- ----------------------------
CREATE TABLE IF NOT EXISTS `AspNetUserLogins`  (
  `LoginProvider` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `ProviderKey` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `ProviderDisplayName` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  `UserId` bigint(20) NOT NULL,
  PRIMARY KEY (`LoginProvider`, `ProviderKey`) USING BTREE,
  INDEX `IX_AspNetUserLogins_UserId`(`UserId` ASC) USING BTREE,
  CONSTRAINT `FK_AspNetUserLogins_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `AspNetUsers` (`Id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for AspNetUserRoles
-- ----------------------------
CREATE TABLE IF NOT EXISTS `AspNetUserRoles`  (
  `UserId` bigint(20) NOT NULL,
  `RoleId` bigint(20) NOT NULL,
  PRIMARY KEY (`UserId`, `RoleId`) USING BTREE,
  INDEX `IX_AspNetUserRoles_RoleId`(`RoleId` ASC) USING BTREE,
  CONSTRAINT `FK_AspNetUserRoles_AspNetRoles_RoleId` FOREIGN KEY (`RoleId`) REFERENCES `AspNetRoles` (`Id`) ON DELETE CASCADE ON UPDATE RESTRICT,
  CONSTRAINT `FK_AspNetUserRoles_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `AspNetUsers` (`Id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for AspNetUserTokens
-- ----------------------------
CREATE TABLE IF NOT EXISTS `AspNetUserTokens`  (
  `UserId` bigint(20) NOT NULL,
  `LoginProvider` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `Name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `Value` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  PRIMARY KEY (`UserId`, `LoginProvider`, `Name`) USING BTREE,
  CONSTRAINT `FK_AspNetUserTokens_AspNetUsers_UserId` FOREIGN KEY (`UserId`) REFERENCES `AspNetUsers` (`Id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for AspNetUsers
-- ----------------------------
CREATE TABLE IF NOT EXISTS `AspNetUsers`  (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `NickName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `CreatedDate` datetime NOT NULL,
  `UpdatedDate` datetime NOT NULL,
  `LastLoginDate` datetime NOT NULL,
  `LastLoginIp` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `LastLoginDevice` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `UserName` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `NormalizedUserName` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `Email` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `NormalizedEmail` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `EmailConfirmed` tinyint(1) NOT NULL,
  `PasswordHash` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  `SecurityStamp` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  `ConcurrencyStamp` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  `PhoneNumber` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  `PhoneNumberConfirmed` tinyint(1) NOT NULL,
  `TwoFactorEnabled` tinyint(1) NOT NULL,
  `LockoutEnd` datetime(6) NULL DEFAULT NULL,
  `LockoutEnabled` tinyint(1) NULL DEFAULT NULL,
  `AccessFailedCount` int(11) NULL DEFAULT NULL,
  `FreeCount` bigint(20) NOT NULL DEFAULT 5 COMMENT '免费修改机器码的次数',
  `AgentPercent` double NOT NULL DEFAULT 0.5 COMMENT '代理分成的百分比',
  `AllDeviceCount` bigint(10) NOT NULL DEFAULT 1 COMMENT '可用的机器码数量（买了几次）',
  `Options` json NULL,
  `ParentId` bigint(20) NULL DEFAULT NULL,
  `AffiliateCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  PRIMARY KEY (`Id`) USING BTREE,
  UNIQUE INDEX `UserNameIndex`(`NormalizedUserName` ASC) USING BTREE,
  INDEX `EmailIndex`(`NormalizedEmail` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for Machine
-- ----------------------------
CREATE TABLE IF NOT EXISTS `Machine`  (
  `Id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'ID',
  `MachineId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用户电脑的机器码',
  `CreateTime` datetime NOT NULL COMMENT '创建时间',
  `UpdateTime` datetime NOT NULL COMMENT '更新时间',
  `DeactivationTime` datetime NULL DEFAULT NULL COMMENT '停用时间',
  `Status` int(11) NOT NULL COMMENT '状态 （激活/冻结）',
  `CreateId` bigint(20) NOT NULL COMMENT '创建者ID',
  `UpdateId` bigint(20) NOT NULL COMMENT '更新者ID',
  `UseStatus` int(11) NOT NULL COMMENT '使用状态（使用/永久）',
  `Remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `UserID` bigint(20) NOT NULL COMMENT '机器码所属ID',
  PRIMARY KEY (`Id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for Permission
-- ----------------------------
CREATE TABLE IF NOT EXISTS `Permission`  (
  `Id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '权限的ID',
  `UserId` bigint(20) NULL DEFAULT NULL COMMENT '用户的ID',
  `MachineId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '机器码的ID（是ID，不是机器码）',
  `RoleId` bigint(20) NULL DEFAULT NULL COMMENT '角色ID',
  `PermissionTypeIds` json NULL COMMENT '权限类型的ID（子权限）',
  `PermissionCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '权限对应的Code',
  `CreateUserId` bigint(20) NOT NULL COMMENT '创建人ID',
  `UpdateUserId` bigint(20) NOT NULL COMMENT '更新人ID',
  `CreateTime` datetime NOT NULL COMMENT '创建时间',
  `UpdateTime` datetime NOT NULL COMMENT '更新时间',
  `Remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `Type` int(11) NOT NULL COMMENT '对应的类型\r\n对应 User，Role，Machine\r\n设置对应的type 检查对应的属性数据是不是存在\r\n',
  PRIMARY KEY (`Id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for PermissionType
-- ----------------------------
CREATE TABLE IF NOT EXISTS `PermissionType`  (
  `Id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '权限ID',
  `Name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '权限的名字',
  `Code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '表示权限的代码',
  `Type` int(11) NOT NULL COMMENT '权限的分类（user和machine，role，prompt,permission，自定义）',
  `CreateUserId` bigint(20) NOT NULL COMMENT '创建者ID',
  `CreateTime` datetime NOT NULL COMMENT '创建时间',
  `UpdateUserId` bigint(20) NOT NULL COMMENT '更新者ID',
  `UpdateTime` datetime NOT NULL COMMENT '更新权限类型的时间',
  `Remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '权限的描述',
  PRIMARY KEY (`Id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for Prompt
-- ----------------------------
CREATE TABLE IF NOT EXISTS `Prompt`  (
  `Id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'ID',
  `Name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '提示词预设的名称',
  `PromptTypeId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '提示词的类型ID',
  `PromptTypeCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '提示词的类型编码',
  `PromptString` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '提示词预设字符串',
  `Version` int(11) NOT NULL COMMENT '当前版本',
  `Status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '状态',
  `Description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '提示词的描述',
  `CreateUserId` bigint(20) NOT NULL COMMENT '创建者',
  `CreateTime` datetime NOT NULL COMMENT '创建时间',
  `UpdateUserId` bigint(20) NOT NULL COMMENT '更新者',
  `UpdateTime` datetime NOT NULL COMMENT '更新时间',
  `Remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`Id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '存放提示词的表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for PromptType
-- ----------------------------
CREATE TABLE IF NOT EXISTS `PromptType`  (
  `Id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'ID',
  `Code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '提示词类型编码',
  `Name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '提示词类型名称',
  `Remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '提示词类型描述',
  `Status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '提示词类型状态',
  `IsDeleted` tinyint(1) NOT NULL COMMENT '是否删除',
  `CreateUserId` bigint(20) NOT NULL COMMENT '创建用户ID',
  `CreateTime` datetime NOT NULL COMMENT '创建时间',
  `UpdateUserId` bigint(20) NOT NULL COMMENT '更新者ID',
  `UpdateTime` datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`Id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '提示词类型的库' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for RefreshTokens
-- ----------------------------
CREATE TABLE IF NOT EXISTS `RefreshTokens`  (
  `Id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'ID ',
  `UserId` bigint(20) NOT NULL COMMENT '用户ID\r\n',
  `Token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '刷新token',
  `Expiration` datetime NOT NULL COMMENT '到期时间',
  `Revoked` bit(1) NOT NULL COMMENT '是不是失效',
  `CreatedTime` datetime NOT NULL COMMENT '创建时间',
  `LastCheckIp` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '上次校验IP',
  `DeviceInfo` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备信息，浏览器信息等',
  PRIMARY KEY (`Id` DESC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for RsaKeys
-- ----------------------------
CREATE TABLE IF NOT EXISTS `RsaKeys`  (
  `Id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'ID 主键',
  `PublicKey` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '公钥',
  `EncryptedPrivateKey` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '加密后的私钥',
  `EncryptionKey` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '加密私钥的随机字符串',
  `EncryptionIV` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '加密私钥的IV',
  `KeyVersion` int(11) NOT NULL COMMENT 'Key的版本',
  `CreatedTime` datetime NOT NULL COMMENT '创建时间',
  `LastUsed` datetime NULL DEFAULT NULL COMMENT '上次使用的时间',
  `UseCount` int(11) NOT NULL DEFAULT 0 COMMENT '使用的次数',
  `ExpirationTime` datetime NOT NULL COMMENT '到期时间',
  PRIMARY KEY (`Id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'RSA密钥存储表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for __EFMigrationsHistory
-- ----------------------------
CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory`  (
  `MigrationId` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `ProductVersion` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  PRIMARY KEY (`MigrationId`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;
