20230201-init.php 21 KB

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