2023020100-init.php 23 KB

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