2023020100-init.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <?php
  2. declare(strict_types=1);
  3. use App\Interfaces\MigrationInterface;
  4. use App\Services\DB;
  5. return new class() implements MigrationInterface {
  6. public function up(): int
  7. {
  8. DB::getPdo()->exec(
  9. "CREATE TABLE `announcement` (
  10. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '公告ID',
  11. `date` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '公告日期',
  12. `content` text NOT NULL DEFAULT '' COMMENT '公告内容',
  13. PRIMARY KEY (`id`)
  14. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  15. CREATE TABLE `config` (
  16. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  17. `item` varchar(255) DEFAULT NULL COMMENT '项',
  18. `value` varchar(2048) DEFAULT NULL COMMENT '值',
  19. `class` varchar(255) DEFAULT 'default' COMMENT '配置分类',
  20. `is_public` int(11) DEFAULT 0 COMMENT '是否为公共参数',
  21. `type` varchar(255) DEFAULT NULL COMMENT '值类型',
  22. `default` varchar(255) DEFAULT NULL COMMENT '默认值',
  23. `mark` varchar(255) DEFAULT NULL COMMENT '备注',
  24. PRIMARY KEY (`id`)
  25. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  26. CREATE TABLE `detect_ban_log` (
  27. `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  28. `user_name` varchar(255) NOT NULL DEFAULT '' COMMENT '用户名',
  29. `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
  30. `email` varchar(255) NOT NULL DEFAULT '' COMMENT '用户邮箱',
  31. `detect_number` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '本次违规次数',
  32. `ban_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '本次封禁时长',
  33. `start_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '统计开始时间',
  34. `end_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '统计结束时间',
  35. `all_detect_number` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '累计违规次数',
  36. PRIMARY KEY (`id`),
  37. KEY `user_id` (`user_id`)
  38. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  39. CREATE TABLE `detect_list` (
  40. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '审计规则ID',
  41. `name` varchar(255) NOT NULL DEFAULT '' COMMENT '规则名称',
  42. `text` varchar(255) NOT NULL DEFAULT '' COMMENT '规则名称',
  43. `regex` varchar(255) NOT NULL DEFAULT '' COMMENT '正则表达式',
  44. `type` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '规则类型',
  45. PRIMARY KEY (`id`)
  46. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  47. CREATE TABLE `detect_log` (
  48. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  49. `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
  50. `list_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '规则ID',
  51. `datetime` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '触发时间',
  52. `node_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '节点ID',
  53. `status` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '状态',
  54. PRIMARY KEY (`id`),
  55. KEY `user_id` (`user_id`),
  56. KEY `node_id` (`node_id`),
  57. KEY `list_id` (`list_id`)
  58. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  59. CREATE TABLE `docs` (
  60. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  61. `date` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '文档日期',
  62. `title` varchar(255) NOT NULL DEFAULT '' COMMENT '文档标题',
  63. `content` longtext NOT NULL DEFAULT '' COMMENT '文档内容',
  64. PRIMARY KEY (`id`)
  65. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  66. CREATE TABLE `email_queue` (
  67. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  68. `to_email` varchar(255) NOT NULL DEFAULT '' COMMENT '收件人邮箱',
  69. `subject` varchar(255) NOT NULL DEFAULT '' COMMENT '邮件标题',
  70. `template` varchar(255) NOT NULL DEFAULT '' COMMENT '邮件模板',
  71. `array` longtext NOT NULL DEFAULT '{}' COMMENT '模板参数' CHECK (json_valid(`array`)),
  72. `time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '添加时间',
  73. PRIMARY KEY (`id`)
  74. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  75. CREATE TABLE `gift_card` (
  76. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '礼品卡ID',
  77. `card` text NOT NULL DEFAULT '' COMMENT '卡号',
  78. `balance` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '余额',
  79. `create_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
  80. `status` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '使用状态',
  81. `use_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '使用时间',
  82. `use_user` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '使用用户',
  83. PRIMARY KEY (`id`),
  84. KEY `id` (`id`),
  85. KEY `status` (`status`)
  86. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  87. CREATE TABLE `invoice` (
  88. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '账单ID',
  89. `user_id` bigint(20) unsigned DEFAULT 0 COMMENT '归属用户',
  90. `order_id` bigint(20) unsigned DEFAULT 0 COMMENT '订单ID',
  91. `content` longtext DEFAULT '{}' COMMENT '账单内容' CHECK (json_valid(`content`)),
  92. `price` double unsigned DEFAULT 0 COMMENT '账单金额',
  93. `status` varchar(255) DEFAULT '' COMMENT '账单状态',
  94. `create_time` int(11) unsigned DEFAULT 0 COMMENT '创建时间',
  95. `update_time` int(11) unsigned DEFAULT 0 COMMENT '更新时间',
  96. `pay_time` int(11) unsigned DEFAULT 0 COMMENT '支付时间',
  97. PRIMARY KEY (`id`),
  98. KEY `id` (`id`),
  99. KEY `user_id` (`user_id`),
  100. KEY `order_id` (`order_id`),
  101. KEY `status` (`status`)
  102. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  103. CREATE TABLE `link` (
  104. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  105. `token` varchar(255) NOT NULL DEFAULT '' COMMENT '订阅token',
  106. `userid` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
  107. PRIMARY KEY (`id`),
  108. UNIQUE KEY `token` (`token`),
  109. UNIQUE KEY `userid` (`userid`)
  110. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  111. CREATE TABLE `login_ip` (
  112. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  113. `userid` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
  114. `ip` varchar(255) NOT NULL DEFAULT '' COMMENT '登录IP',
  115. `datetime` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '登录时间',
  116. `type` tinyint(1) unsigned NOT NULL DEFAULT 1 COMMENT '登录类型',
  117. PRIMARY KEY (`id`),
  118. KEY `userid` (`userid`),
  119. KEY `type` (`type`)
  120. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  121. CREATE TABLE `node` (
  122. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '节点ID',
  123. `name` varchar(255) NOT NULL DEFAULT '' COMMENT '节点名称',
  124. `type` tinyint(1) unsigned NOT NULL DEFAULT 1 COMMENT '节点显示',
  125. `server` varchar(255) NOT NULL DEFAULT '' COMMENT '节点地址',
  126. `custom_config` longtext NOT NULL DEFAULT '{}' COMMENT '自定义配置' CHECK (json_valid(`custom_config`)),
  127. `info` varchar(255) NOT NULL DEFAULT '' COMMENT '节点信息',
  128. `status` varchar(255) NOT NULL DEFAULT '' COMMENT '节点状态',
  129. `sort` tinyint(2) unsigned NOT NULL DEFAULT 14 COMMENT '节点类型',
  130. `traffic_rate` float unsigned NOT NULL DEFAULT 1 COMMENT '流量倍率',
  131. `is_dynamic_rate` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否启用动态流量倍率',
  132. `dynamic_rate_config` longtext NOT NULL DEFAULT '{}' COMMENT '动态流量倍率配置' CHECK (json_valid(`custom_config`)),
  133. `node_class` smallint(5) unsigned NOT NULL DEFAULT 0 COMMENT '节点等级',
  134. `node_speedlimit` double unsigned NOT NULL DEFAULT 0 COMMENT '节点限速',
  135. `node_bandwidth` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '节点流量',
  136. `node_bandwidth_limit` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '节点流量限制',
  137. `bandwidthlimit_resetday` tinyint(2) unsigned NOT NULL DEFAULT 0 COMMENT '流量重置日',
  138. `node_heartbeat` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '节点心跳',
  139. `online_user` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '节点在线用户',
  140. `node_ip` varchar(255) NOT NULL DEFAULT '' COMMENT '节点IP',
  141. `node_group` smallint(5) unsigned NOT NULL DEFAULT 0 COMMENT '节点群组',
  142. `online` tinyint(1) NOT NULL DEFAULT 1 COMMENT '在线状态',
  143. `gfw_block` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否被GFW封锁',
  144. `password` varchar(255) NOT NULL DEFAULT '' COMMENT '后端连接密码',
  145. PRIMARY KEY (`id`),
  146. KEY `type` (`type`),
  147. KEY `sort` (`sort`),
  148. KEY `node_class` (`node_class`),
  149. KEY `node_group` (`node_group`),
  150. KEY `online` (`online`)
  151. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  152. CREATE TABLE `online_log` (
  153. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  154. `user_id` bigint(20) unsigned NOT NULL COMMENT '用户ID',
  155. `ip` inet6 NOT NULL COMMENT 'IP地址',
  156. `node_id` int(11) unsigned NOT NULL COMMENT '节点ID',
  157. `first_time` int(11) unsigned NOT NULL COMMENT '首次在线时间',
  158. `last_time` int(11) unsigned NOT NULL COMMENT '最后在线时间',
  159. PRIMARY KEY (`id`),
  160. UNIQUE KEY (`user_id`, `ip`),
  161. KEY (`last_time`)
  162. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  163. CREATE TABLE `order` (
  164. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '订单ID',
  165. `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '提交用户',
  166. `product_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '商品ID',
  167. `product_type` varchar(255) NOT NULL DEFAULT '' COMMENT '商品类型',
  168. `product_name` varchar(255) NOT NULL DEFAULT '' COMMENT '商品名称',
  169. `product_content` longtext NOT NULL DEFAULT '{}' COMMENT '商品内容' CHECK (json_valid(`product_content`)),
  170. `coupon` varchar(255) NOT NULL DEFAULT '' COMMENT '订单优惠码',
  171. `price` double unsigned NOT NULL DEFAULT 0 COMMENT '订单金额',
  172. `status` varchar(255) NOT NULL DEFAULT '' COMMENT '订单状态',
  173. `create_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
  174. `update_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '更新时间',
  175. PRIMARY KEY (`id`),
  176. KEY `id` (`id`),
  177. KEY `user_id` (`user_id`),
  178. KEY `product_id` (`product_id`),
  179. KEY `status` (`status`)
  180. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  181. CREATE TABLE `payback` (
  182. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  183. `total` decimal(12,2) unsigned NOT NULL DEFAULT 0 COMMENT '总金额',
  184. `userid` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
  185. `ref_by` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '推荐人ID',
  186. `ref_get` decimal(12,2) unsigned NOT NULL DEFAULT 0 COMMENT '推荐人获得金额',
  187. `datetime` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
  188. PRIMARY KEY (`id`)
  189. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  190. CREATE TABLE `paylist` (
  191. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  192. `userid` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
  193. `total` decimal(12,2) NOT NULL DEFAULT 0 COMMENT '总金额',
  194. `status` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '状态',
  195. `invoice_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账单ID',
  196. `tradeno` varchar(255) NOT NULL DEFAULT '' COMMENT '网关单号',
  197. `gateway` varchar(255) NOT NULL DEFAULT '' COMMENT '支付网关',
  198. `datetime` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
  199. PRIMARY KEY (`id`),
  200. KEY `userid` (`userid`)
  201. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  202. CREATE TABLE `product` (
  203. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '商品ID',
  204. `type` varchar(255) NOT NULL DEFAULT 'tabp' COMMENT '类型',
  205. `name` varchar(255) NOT NULL DEFAULT '' COMMENT '名称',
  206. `price` double unsigned NOT NULL DEFAULT 0 COMMENT '售价',
  207. `content` longtext NOT NULL DEFAULT '{}' COMMENT '内容' CHECK (json_valid(`content`)),
  208. `limit` longtext NOT NULL DEFAULT '{}' COMMENT '购买限制' CHECK (json_valid(`limit`)),
  209. `status` tinyint(1) unsigned NOT NULL DEFAULT 1 COMMENT '销售状态',
  210. `create_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
  211. `update_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '更新时间',
  212. `sale_count` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '累计销售数',
  213. `stock` int(11) NOT NULL DEFAULT -1 COMMENT '库存',
  214. PRIMARY KEY (`id`),
  215. KEY `id` (`id`),
  216. KEY `type` (`type`),
  217. KEY `status` (`status`)
  218. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  219. CREATE TABLE `subscribe_log` (
  220. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  221. `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
  222. `type` varchar(255) NOT NULL DEFAULT '' COMMENT '获取的订阅类型',
  223. `request_ip` varchar(255) NOT NULL DEFAULT '' COMMENT '请求IP',
  224. `request_user_agent` varchar(255) NOT NULL DEFAULT '' COMMENT '请求UA信息',
  225. `request_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '请求时间',
  226. PRIMARY KEY (`id`),
  227. KEY `user_id` (`user_id`)
  228. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  229. CREATE TABLE `ticket` (
  230. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '工单ID',
  231. `title` varchar(255) NOT NULL DEFAULT '' COMMENT '工单标题',
  232. `content` longtext NOT NULL DEFAULT '{}' COMMENT '工单内容' CHECK (json_valid(`content`)),
  233. `userid` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
  234. `datetime` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
  235. `status` varchar(255) NOT NULL DEFAULT '' COMMENT '工单状态',
  236. `type` varchar(255) NOT NULL DEFAULT '' COMMENT '工单类型',
  237. PRIMARY KEY (`id`),
  238. KEY `userid` (`userid`),
  239. KEY `status` (`status`)
  240. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  241. CREATE TABLE `user` (
  242. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户ID',
  243. `user_name` varchar(255) NOT NULL DEFAULT '' COMMENT '用户名',
  244. `email` varchar(255) NOT NULL COMMENT 'E-Mail',
  245. `pass` varchar(255) NOT NULL COMMENT '登录密码',
  246. `passwd` varchar(255) NOT NULL COMMENT '节点密码',
  247. `uuid` char(36) NOT NULL COMMENT 'UUID',
  248. `u` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户当前上传流量',
  249. `d` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户当前下载流量',
  250. `transfer_today` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户今日所用流量',
  251. `transfer_total` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户累计使用流量',
  252. `transfer_enable` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户当前可用流量',
  253. `port` smallint(6) unsigned NOT NULL COMMENT '端口',
  254. `last_detect_ban_time` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '最后一次被封禁的时间',
  255. `all_detect_number` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '累计违规次数',
  256. `last_use_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '最后使用时间',
  257. `last_check_in_time` int(11) unsigned DEFAULT 0 COMMENT '最后签到时间',
  258. `last_login_time` int(11) unsigned DEFAULT 0 COMMENT '最后登录时间',
  259. `reg_date` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '注册时间',
  260. `invite_num` int(11) NOT NULL DEFAULT 0 COMMENT '可用邀请次数',
  261. `money` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '账户余额',
  262. `ref_by` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '邀请人ID',
  263. `method` varchar(255) NOT NULL DEFAULT 'aes-128-gcm' COMMENT 'Shadowsocks加密方式',
  264. `reg_ip` varchar(255) NOT NULL DEFAULT '127.0.0.1' COMMENT '注册IP',
  265. `node_speedlimit` double NOT NULL DEFAULT 0 COMMENT '用户限速',
  266. `node_iplimit` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '同时可连接IP数',
  267. `is_admin` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否管理员',
  268. `im_type` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '联系方式类型',
  269. `im_value` varchar(255) NOT NULL DEFAULT '' COMMENT '联系方式',
  270. `contact_method` smallint(6) NOT NULL DEFAULT 1 COMMENT '偏好的联系方式',
  271. `daily_mail_enable` tinyint(1) NOT NULL DEFAULT 0 COMMENT '每日报告开关',
  272. `class` smallint(5) unsigned NOT NULL DEFAULT 0 COMMENT '等级',
  273. `class_expire` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '等级过期时间',
  274. `theme` varchar(255) NOT NULL DEFAULT 'tabler' COMMENT '网站主题',
  275. `ga_token` varchar(255) NOT NULL DEFAULT '' COMMENT 'GA密钥',
  276. `ga_enable` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'GA开关',
  277. `remark` text NOT NULL DEFAULT '' COMMENT '备注',
  278. `node_group` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '节点分组',
  279. `is_banned` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否封禁',
  280. `banned_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '封禁理由',
  281. `is_shadow_banned` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否处于账户异常状态',
  282. `expire_notified` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '过期提醒',
  283. `traffic_notified` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '流量提醒',
  284. `forbidden_ip` varchar(255) NOT NULL DEFAULT '' COMMENT '禁止访问IP',
  285. `forbidden_port` varchar(255) NOT NULL DEFAULT '' COMMENT '禁止访问端口',
  286. `auto_reset_day` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '自动重置流量日',
  287. `auto_reset_bandwidth` decimal(12,2) unsigned NOT NULL DEFAULT 0 COMMENT '自动重置流量',
  288. `api_token` char(36) NOT NULL DEFAULT '' COMMENT 'API 密钥',
  289. `is_dark_mode` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否启用暗黑模式',
  290. `is_inactive` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否处于闲置状态',
  291. `locale` varchar(16) NOT NULL DEFAULT 'zh-TW' COMMENT '显示语言',
  292. PRIMARY KEY (`id`),
  293. UNIQUE KEY `uuid` (`uuid`),
  294. UNIQUE KEY `email` (`email`),
  295. UNIQUE KEY `ga_token` (`ga_token`),
  296. UNIQUE KEY `api_token` (`api_token`),
  297. KEY `is_admin` (`is_admin`),
  298. KEY `is_banned` (`is_banned`),
  299. KEY `is_inactive` (`is_inactive`)
  300. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  301. CREATE TABLE `user_coupon` (
  302. `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '优惠码ID',
  303. `code` varchar(255) NOT NULL DEFAULT '' COMMENT '优惠码',
  304. `content` longtext NOT NULL DEFAULT '{}' COMMENT '优惠码内容' CHECK (json_valid(`content`)),
  305. `limit` longtext NOT NULL DEFAULT '{}' COMMENT '优惠码限制' CHECK (json_valid(`limit`)),
  306. `use_count` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '累计使用次数',
  307. `create_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
  308. `expire_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '过期时间',
  309. PRIMARY KEY (`id`),
  310. KEY `id` (`id`),
  311. KEY `code` (`code`),
  312. KEY `expire_time` (`expire_time`)
  313. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  314. CREATE TABLE `user_hourly_usage` (
  315. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  316. `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
  317. `traffic` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '当前总流量',
  318. `hourly_usage` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '过去一小时流量',
  319. `datetime` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '记录时间',
  320. PRIMARY KEY (`id`),
  321. KEY `user_id` (`user_id`)
  322. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  323. CREATE TABLE `user_invite_code` (
  324. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  325. `code` varchar(255) NOT NULL DEFAULT '' COMMENT '邀请码',
  326. `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
  327. `created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '创建时间',
  328. `updated_at` timestamp NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '更新时间',
  329. PRIMARY KEY (`id`),
  330. UNIQUE KEY `code` (`code`),
  331. UNIQUE KEY `user_id` (`user_id`)
  332. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  333. CREATE TABLE `user_money_log` (
  334. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
  335. `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
  336. `before` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '用户变动前账户余额',
  337. `after` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '用户变动后账户余额',
  338. `amount` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '变动总额',
  339. `remark` text NOT NULL DEFAULT '' COMMENT '备注',
  340. `create_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
  341. PRIMARY KEY (`id`),
  342. KEY `user_id` (`user_id`)
  343. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
  344. );
  345. return 2023020100;
  346. }
  347. public function down(): int
  348. {
  349. echo "No reverse operation for initial migration\n";
  350. return 2023020100;
  351. }
  352. };