2023020100-init.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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 `alive_ip` (
  10. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  11. `nodeid` int(11) DEFAULT NULL,
  12. `userid` int(11) DEFAULT NULL,
  13. `ip` varchar(255) DEFAULT NULL,
  14. `datetime` bigint(20) DEFAULT NULL,
  15. PRIMARY KEY (`id`)
  16. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  17. CREATE TABLE `announcement` (
  18. `id` int(11) NOT NULL AUTO_INCREMENT,
  19. `date` datetime DEFAULT NULL,
  20. `content` text DEFAULT NULL,
  21. PRIMARY KEY (`id`)
  22. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  23. CREATE TABLE `bought` (
  24. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  25. `userid` bigint(20) DEFAULT NULL,
  26. `shopid` bigint(20) DEFAULT NULL,
  27. `datetime` bigint(20) DEFAULT NULL,
  28. `renew` bigint(20) DEFAULT NULL,
  29. `coupon` varchar(255) DEFAULT NULL,
  30. `price` decimal(12,2) DEFAULT NULL,
  31. `is_notified` tinyint(1) DEFAULT 0,
  32. PRIMARY KEY (`id`)
  33. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  34. CREATE TABLE `code` (
  35. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  36. `code` varchar(255) DEFAULT NULL,
  37. `type` int(11) DEFAULT NULL,
  38. `number` decimal(12,2) DEFAULT NULL,
  39. `isused` int(11) DEFAULT 0,
  40. `userid` bigint(20) DEFAULT NULL,
  41. `usedatetime` datetime DEFAULT NULL,
  42. PRIMARY KEY (`id`)
  43. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  44. CREATE TABLE `config` (
  45. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  46. `item` varchar(255) DEFAULT NULL COMMENT '项',
  47. `value` varchar(2048) DEFAULT NULL,
  48. `class` varchar(255) DEFAULT 'default' COMMENT '配置分类',
  49. `is_public` int(11) DEFAULT 0 COMMENT '是否为公共参数',
  50. `type` varchar(255) DEFAULT NULL COMMENT '值类型',
  51. `default` varchar(255) DEFAULT NULL COMMENT '默认值',
  52. `mark` varchar(255) DEFAULT NULL COMMENT '备注',
  53. PRIMARY KEY (`id`)
  54. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  55. CREATE TABLE `coupon` (
  56. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  57. `code` varchar(255) DEFAULT NULL,
  58. `onetime` int(11) DEFAULT NULL,
  59. `expire` bigint(20) DEFAULT NULL,
  60. `shop` varchar(255) DEFAULT NULL,
  61. `credit` int(11) DEFAULT NULL,
  62. PRIMARY KEY (`id`)
  63. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  64. CREATE TABLE `detect_ban_log` (
  65. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  66. `user_name` varchar(255) DEFAULT NULL COMMENT '用户名',
  67. `user_id` bigint(20) unsigned DEFAULT NULL COMMENT '用户 ID',
  68. `email` varchar(255) DEFAULT NULL COMMENT '用户邮箱',
  69. `detect_number` int(11) DEFAULT NULL COMMENT '本次违规次数',
  70. `ban_time` int(11) DEFAULT NULL COMMENT '本次封禁时长',
  71. `start_time` bigint(20) DEFAULT NULL COMMENT '统计开始时间',
  72. `end_time` bigint(20) DEFAULT NULL COMMENT '统计结束时间',
  73. `all_detect_number` int(11) DEFAULT NULL COMMENT '累计违规次数',
  74. PRIMARY KEY (`id`),
  75. KEY `user_id` (`user_id`)
  76. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  77. CREATE TABLE `detect_list` (
  78. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  79. `name` varchar(255) DEFAULT NULL,
  80. `text` varchar(255) DEFAULT NULL,
  81. `regex` varchar(255) DEFAULT NULL,
  82. `type` int(11) DEFAULT NULL,
  83. PRIMARY KEY (`id`)
  84. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  85. CREATE TABLE `detect_log` (
  86. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  87. `user_id` bigint(20) unsigned DEFAULT NULL,
  88. `list_id` bigint(20) unsigned DEFAULT NULL,
  89. `datetime` bigint(20) unsigned DEFAULT NULL,
  90. `node_id` int(11) DEFAULT NULL,
  91. `status` int(11) DEFAULT 0,
  92. PRIMARY KEY (`id`),
  93. KEY `user_id` (`user_id`),
  94. KEY `node_id` (`node_id`),
  95. KEY `list_id` (`list_id`)
  96. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  97. CREATE TABLE `docs` (
  98. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  99. `date` datetime DEFAULT NULL,
  100. `title` varchar(255) DEFAULT NULL,
  101. `content` varchar(255) DEFAULT NULL,
  102. `markdown` varchar(255) DEFAULT NULL,
  103. PRIMARY KEY (`id`)
  104. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  105. CREATE TABLE `email_queue` (
  106. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  107. `to_email` varchar(255) DEFAULT NULL,
  108. `subject` varchar(255) DEFAULT NULL,
  109. `template` varchar(255) DEFAULT NULL,
  110. `array` longtext DEFAULT NULL,
  111. `time` int(11) DEFAULT NULL,
  112. PRIMARY KEY (`id`)
  113. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  114. CREATE TABLE `email_verify` (
  115. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  116. `email` varchar(255) DEFAULT NULL,
  117. `ip` varchar(255) DEFAULT NULL,
  118. `code` varchar(255) DEFAULT NULL,
  119. `expire_in` bigint(20) DEFAULT NULL,
  120. PRIMARY KEY (`id`)
  121. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  122. CREATE TABLE `gift_card` (
  123. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  124. `card` text DEFAULT NULL COMMENT '卡号',
  125. `balance` int(11) DEFAULT NULL COMMENT '余额',
  126. `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
  127. `status` int(11) DEFAULT NULL COMMENT '使用状态',
  128. `use_time` int(11) DEFAULT NULL COMMENT '使用时间',
  129. `use_user` int(11) DEFAULT NULL COMMENT '使用用户',
  130. PRIMARY KEY (`id`),
  131. KEY `id` (`id`),
  132. KEY `status` (`status`)
  133. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  134. CREATE TABLE `invoice` (
  135. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '账单ID',
  136. `user_id` int(11) DEFAULT NULL COMMENT '归属用户',
  137. `order_id` int(11) DEFAULT NULL COMMENT '订单ID',
  138. `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '账单内容' CHECK (json_valid(`content`)),
  139. `price` double DEFAULT NULL COMMENT '账单金额',
  140. `status` varchar(255) DEFAULT NULL COMMENT '账单状态',
  141. `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
  142. `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
  143. `pay_time` int(11) DEFAULT NULL COMMENT '支付时间',
  144. PRIMARY KEY (`id`),
  145. KEY `id` (`id`),
  146. KEY `user_id` (`user_id`),
  147. KEY `order_id` (`order_id`),
  148. KEY `status` (`status`)
  149. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  150. CREATE TABLE `link` (
  151. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  152. `token` varchar(255) DEFAULT NULL,
  153. `userid` bigint(20) unsigned DEFAULT NULL,
  154. PRIMARY KEY (`id`),
  155. UNIQUE KEY `token` (`token`),
  156. UNIQUE KEY `userid` (`userid`)
  157. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  158. CREATE TABLE `login_ip` (
  159. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  160. `userid` bigint(20) unsigned DEFAULT NULL,
  161. `ip` varchar(255) DEFAULT NULL,
  162. `datetime` bigint(20) DEFAULT NULL,
  163. `type` int(11) DEFAULT NULL,
  164. PRIMARY KEY (`id`),
  165. KEY `userid` (`userid`)
  166. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  167. CREATE TABLE `node` (
  168. `id` int(11) NOT NULL AUTO_INCREMENT,
  169. `name` varchar(255) DEFAULT NULL,
  170. `type` int(11) DEFAULT NULL,
  171. `server` varchar(255) DEFAULT NULL,
  172. `custom_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '{}' COMMENT '自定义配置' CHECK (json_valid(`custom_config`)),
  173. `info` text DEFAULT '',
  174. `status` varchar(255) DEFAULT '',
  175. `sort` int(11) DEFAULT NULL,
  176. `traffic_rate` float DEFAULT 1,
  177. `node_class` int(11) DEFAULT 0,
  178. `node_speedlimit` double NOT NULL DEFAULT 0 COMMENT '节点限速',
  179. `node_connector` int(11) DEFAULT 0,
  180. `node_bandwidth` bigint(20) DEFAULT 0,
  181. `node_bandwidth_limit` bigint(20) DEFAULT 0,
  182. `bandwidthlimit_resetday` int(11) DEFAULT 0,
  183. `node_heartbeat` bigint(20) DEFAULT 0,
  184. `online_user` int(11) DEFAULT 0 COMMENT '节点在线用户',
  185. `node_ip` varchar(255) DEFAULT NULL,
  186. `node_group` int(11) DEFAULT 0,
  187. `mu_only` tinyint(1) DEFAULT 0,
  188. `online` tinyint(1) DEFAULT 1,
  189. `gfw_block` tinyint(1) DEFAULT 0,
  190. `password` varchar(255) DEFAULT NULL,
  191. PRIMARY KEY (`id`)
  192. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  193. CREATE TABLE `order` (
  194. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '订单ID',
  195. `user_id` int(11) DEFAULT NULL COMMENT '提交用户',
  196. `product_id` int(11) DEFAULT NULL COMMENT '商品ID',
  197. `product_type` varchar(255) DEFAULT NULL COMMENT '商品类型',
  198. `product_name` varchar(255) DEFAULT NULL COMMENT '商品名称',
  199. `product_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '商品内容' CHECK (json_valid(`product_content`)),
  200. `coupon` varchar(255) DEFAULT NULL COMMENT '订单优惠码',
  201. `price` double DEFAULT NULL COMMENT '订单金额',
  202. `status` varchar(255) DEFAULT NULL COMMENT '订单状态',
  203. `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
  204. `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
  205. PRIMARY KEY (`id`),
  206. KEY `id` (`id`),
  207. KEY `user_id` (`user_id`),
  208. KEY `product_id` (`product_id`),
  209. KEY `status` (`status`)
  210. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  211. CREATE TABLE `payback` (
  212. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  213. `total` decimal(12,2) DEFAULT NULL,
  214. `userid` bigint(20) DEFAULT NULL,
  215. `ref_by` bigint(20) DEFAULT NULL,
  216. `ref_get` decimal(12,2) DEFAULT NULL,
  217. `datetime` bigint(20) DEFAULT NULL,
  218. PRIMARY KEY (`id`)
  219. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  220. CREATE TABLE `paylist` (
  221. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  222. `userid` bigint(20) unsigned DEFAULT NULL,
  223. `total` decimal(12,2) DEFAULT NULL,
  224. `status` int(11) DEFAULT 0,
  225. `invoice_id` int(11) DEFAULT 0,
  226. `tradeno` varchar(255) DEFAULT NULL,
  227. `datetime` bigint(20) DEFAULT 0,
  228. PRIMARY KEY (`id`),
  229. KEY `userid` (`userid`)
  230. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  231. CREATE TABLE `product` (
  232. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '商品ID',
  233. `type` varchar(255) DEFAULT NULL COMMENT '类型',
  234. `name` varchar(255) DEFAULT NULL COMMENT '名称',
  235. `price` double DEFAULT NULL COMMENT '售价',
  236. `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '内容' CHECK (json_valid(`content`)),
  237. `limit` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '购买限制' CHECK (json_valid(`limit`)),
  238. `status` int(11) DEFAULT NULL COMMENT '销售状态',
  239. `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
  240. `update_time` int(11) DEFAULT NULL COMMENT '更新时间',
  241. `sale_count` int(11) DEFAULT NULL COMMENT '累计销售数',
  242. `stock` int(11) DEFAULT NULL COMMENT '库存',
  243. PRIMARY KEY (`id`),
  244. KEY `id` (`id`),
  245. KEY `type` (`type`)
  246. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  247. CREATE TABLE `shop` (
  248. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  249. `name` varchar(255) DEFAULT NULL,
  250. `price` decimal(12,2) DEFAULT NULL,
  251. `content` text DEFAULT NULL,
  252. `auto_renew` int(11) DEFAULT NULL,
  253. `auto_reset_bandwidth` int(11) DEFAULT 0,
  254. `status` int(11) DEFAULT 1,
  255. PRIMARY KEY (`id`)
  256. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  257. CREATE TABLE `stream_media` (
  258. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  259. `node_id` int(11) DEFAULT NULL COMMENT '节点id',
  260. `result` text DEFAULT NULL COMMENT '检测结果',
  261. `created_at` int(11) DEFAULT NULL COMMENT '创建时间',
  262. PRIMARY KEY (`id`)
  263. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  264. CREATE TABLE `telegram_session` (
  265. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  266. `user_id` bigint(20) DEFAULT NULL,
  267. `type` int(11) DEFAULT NULL,
  268. `session_content` varchar(255) DEFAULT NULL,
  269. `datetime` bigint(20) DEFAULT NULL,
  270. PRIMARY KEY (`id`)
  271. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  272. CREATE TABLE `ticket` (
  273. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  274. `title` varchar(255) DEFAULT NULL,
  275. `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '工单内容' CHECK (json_valid(`content`)),
  276. `userid` bigint(20) DEFAULT NULL,
  277. `datetime` bigint(20) DEFAULT NULL,
  278. `status` varchar(255) DEFAULT '' COMMENT '工单状态',
  279. `type` varchar(255) DEFAULT 'other' COMMENT '工单类型',
  280. PRIMARY KEY (`id`)
  281. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  282. CREATE TABLE `user` (
  283. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户ID',
  284. `user_name` varchar(255) DEFAULT NULL COMMENT '用户名',
  285. `email` varchar(255) DEFAULT NULL COMMENT 'E-Mail',
  286. `pass` varchar(255) DEFAULT NULL COMMENT '登录密码',
  287. `passwd` varchar(255) DEFAULT NULL COMMENT '节点密码',
  288. `uuid` char(36) NOT NULL COMMENT 'UUID',
  289. `t` bigint(20) unsigned DEFAULT 0 COMMENT '最后使用时间',
  290. `u` bigint(20) unsigned DEFAULT 0 COMMENT '账户当前上传流量',
  291. `d` bigint(20) unsigned DEFAULT 0 COMMENT '账户当前下载流量',
  292. `transfer_total` bigint(20) unsigned DEFAULT 0 COMMENT '账户累计使用流量',
  293. `transfer_enable` bigint(20) unsigned DEFAULT 0 COMMENT '账户当前可用流量',
  294. `port` smallint(6) unsigned NOT NULL COMMENT '端口',
  295. `last_detect_ban_time` datetime DEFAULT '1989-06-04 00:05:00' COMMENT '最后一次被封禁的时间',
  296. `all_detect_number` int(11) DEFAULT 0 COMMENT '累计违规次数',
  297. `last_check_in_time` bigint(20) unsigned DEFAULT 0 COMMENT '最后签到时间',
  298. `reg_date` datetime DEFAULT NULL COMMENT '注册时间',
  299. `invite_num` int(11) DEFAULT 0 COMMENT '可用邀请次数',
  300. `money` decimal(10,2) NOT NULL DEFAULT 0.00,
  301. `ref_by` bigint(20) unsigned DEFAULT 0 COMMENT '邀请人ID',
  302. `method` varchar(255) DEFAULT 'rc4-md5' COMMENT 'Shadowsocks加密方式',
  303. `reg_ip` varchar(255) DEFAULT '127.0.0.1' COMMENT '注册IP',
  304. `node_speedlimit` double NOT NULL DEFAULT 0 COMMENT '用户限速',
  305. `node_iplimit` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '同时可连接IP数',
  306. `node_connector` int(11) DEFAULT 0 COMMENT '同时可使用连接数',
  307. `is_admin` tinyint(1) DEFAULT 0 COMMENT '是否管理员',
  308. `im_type` int(11) DEFAULT 1 COMMENT '联系方式类型',
  309. `im_value` varchar(255) DEFAULT '' COMMENT '联系方式',
  310. `last_day_t` bigint(20) DEFAULT 0 COMMENT '今天之前已使用的流量',
  311. `sendDailyMail` tinyint(1) DEFAULT 0 COMMENT '每日报告开关',
  312. `class` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '等级',
  313. `class_expire` datetime DEFAULT '1989-06-04 00:05:00' COMMENT '等级过期时间',
  314. `expire_in` datetime DEFAULT '2099-06-04 00:05:00',
  315. `theme` varchar(255) DEFAULT NULL COMMENT '网站主题',
  316. `ga_token` varchar(255) DEFAULT NULL,
  317. `ga_enable` int(11) DEFAULT 0,
  318. `remark` text DEFAULT '' COMMENT '备注',
  319. `node_group` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '节点分组',
  320. `is_banned` int(11) DEFAULT 0 COMMENT '是否封禁',
  321. `banned_reason` varchar(255) DEFAULT '' COMMENT '封禁理由',
  322. `telegram_id` bigint(20) DEFAULT 0,
  323. `expire_notified` tinyint(1) DEFAULT 0,
  324. `traffic_notified` tinyint(1) DEFAULT 0,
  325. `forbidden_ip` varchar(255) DEFAULT '',
  326. `forbidden_port` varchar(255) DEFAULT '',
  327. `auto_reset_day` int(11) DEFAULT 0,
  328. `auto_reset_bandwidth` decimal(12,2) DEFAULT 0.00,
  329. `api_token` char(36) NOT NULL DEFAULT '' COMMENT 'API 密钥',
  330. `use_new_shop` smallint(6) NOT NULL DEFAULT 0 COMMENT '是否启用新商店',
  331. `is_dark_mode` int(11) DEFAULT 0,
  332. PRIMARY KEY (`id`),
  333. UNIQUE KEY `uuid` (`uuid`),
  334. UNIQUE KEY `email` (`email`),
  335. UNIQUE KEY `ga_token` (`ga_token`),
  336. KEY `user_name` (`user_name`)
  337. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  338. CREATE TABLE `user_coupon` (
  339. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '优惠码ID',
  340. `code` varchar(255) DEFAULT NULL COMMENT '优惠码',
  341. `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '优惠码内容' CHECK (json_valid(`content`)),
  342. `limit` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '优惠码限制' CHECK (json_valid(`limit`)),
  343. `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
  344. `expire_time` int(11) DEFAULT NULL COMMENT '过期时间',
  345. PRIMARY KEY (`id`),
  346. KEY `id` (`id`),
  347. KEY `code` (`code`),
  348. KEY `expire_time` (`expire_time`)
  349. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  350. CREATE TABLE `user_hourly_usage` (
  351. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  352. `user_id` bigint(20) unsigned DEFAULT NULL,
  353. `traffic` bigint(20) DEFAULT NULL,
  354. `hourly_usage` bigint(20) DEFAULT NULL,
  355. `datetime` int(11) DEFAULT NULL,
  356. PRIMARY KEY (`id`),
  357. KEY `user_id` (`user_id`)
  358. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  359. CREATE TABLE `user_invite_code` (
  360. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  361. `code` varchar(255) DEFAULT NULL,
  362. `user_id` bigint(20) unsigned DEFAULT NULL,
  363. `created_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  364. `updated_at` timestamp NULL DEFAULT '2016-05-31 15:00:00',
  365. PRIMARY KEY (`id`),
  366. UNIQUE KEY `code` (`code`),
  367. UNIQUE KEY `user_id` (`user_id`)
  368. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  369. CREATE TABLE `user_password_reset` (
  370. `id` int(11) NOT NULL AUTO_INCREMENT,
  371. `email` varchar(255) DEFAULT NULL,
  372. `token` varchar(255) DEFAULT NULL,
  373. `init_time` int(11) DEFAULT NULL,
  374. `expire_time` int(11) DEFAULT NULL,
  375. PRIMARY KEY (`id`)
  376. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  377. CREATE TABLE `user_subscribe_log` (
  378. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  379. `user_name` varchar(255) DEFAULT NULL COMMENT '用户名',
  380. `user_id` bigint(20) unsigned DEFAULT NULL COMMENT '用户 ID',
  381. `email` varchar(255) DEFAULT NULL COMMENT '用户邮箱',
  382. `subscribe_type` varchar(255) DEFAULT NULL COMMENT '获取的订阅类型',
  383. `request_ip` varchar(255) DEFAULT NULL COMMENT '请求 IP',
  384. `request_time` datetime DEFAULT NULL COMMENT '请求时间',
  385. `request_user_agent` text DEFAULT NULL COMMENT '请求 UA 信息',
  386. PRIMARY KEY (`id`),
  387. KEY `user_id` (`user_id`)
  388. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  389. CREATE TABLE `user_token` (
  390. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  391. `token` varchar(255) DEFAULT NULL,
  392. `user_id` bigint(20) unsigned DEFAULT NULL,
  393. `create_time` bigint(20) unsigned DEFAULT NULL,
  394. `expire_time` bigint(20) DEFAULT NULL,
  395. PRIMARY KEY (`id`),
  396. KEY `user_id` (`user_id`)
  397. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
  398. );
  399. return 2023020100;
  400. }
  401. public function down(): int
  402. {
  403. echo "No reverse operation for initial migration\n";
  404. return 2023020100;
  405. }
  406. };