SQL03-数据库升级.sql 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. SET NAMES utf8mb4;
  2. SET FOREIGN_KEY_CHECKS = 0;
  3. -- 尝试创建微信自动回复数据表
  4. CREATE TABLE IF NOT EXISTS `wechat_auto`
  5. (
  6. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  7. `type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '类型(text,image,news)',
  8. `time` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '延迟时间',
  9. `code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '消息编号',
  10. `appid` char(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '公众号APPID',
  11. `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '文本内容',
  12. `image_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '图片链接',
  13. `voice_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '语音链接',
  14. `music_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '音乐标题',
  15. `music_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '音乐链接',
  16. `music_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '缩略图片',
  17. `music_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '音乐描述',
  18. `video_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '视频标题',
  19. `video_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '视频URL',
  20. `video_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '视频描述',
  21. `news_id` bigint(20) UNSIGNED NULL DEFAULT NULL COMMENT '图文ID',
  22. `status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '状态(0禁用,1启用)',
  23. `create_by` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '创建人',
  24. `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  25. PRIMARY KEY (`id`) USING BTREE,
  26. INDEX `idx_wechat_auto_type` (`type`) USING BTREE,
  27. INDEX `idx_wechat_auto_keys` (`time`) USING BTREE,
  28. INDEX `idx_wechat_auto_appid` (`appid`) USING BTREE,
  29. INDEX `idx_wechat_auto_code` (`code`) USING BTREE
  30. ) ENGINE = InnoDB
  31. AUTO_INCREMENT = 1
  32. CHARACTER SET = utf8mb4
  33. COLLATE = utf8mb4_unicode_ci COMMENT = '微信-回复'
  34. ROW_FORMAT = COMPACT;
  35. -- 调整字段名称长度
  36. ALTER TABLE `system_queue`
  37. MODIFY COLUMN `title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '任务名称' AFTER `code`;
  38. -- 尝试创建数据字典数据表
  39. CREATE TABLE IF NOT EXISTS `system_base`
  40. (
  41. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  42. `type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '数据类型',
  43. `code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '数据代码',
  44. `name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '数据名称',
  45. `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '数据内容',
  46. `sort` bigint(20) NULL DEFAULT 0 COMMENT '排序权重',
  47. `status` tinyint(1) NULL DEFAULT 1 COMMENT '数据状态(0禁用,1启动)',
  48. `deleted` tinyint(1) NULL DEFAULT 0 COMMENT '删除状态(0正常,1已删)',
  49. `deleted_at` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '删除时间',
  50. `deleted_by` bigint(20) NULL DEFAULT 0 COMMENT '删除用户',
  51. `create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  52. PRIMARY KEY (`id`) USING BTREE,
  53. INDEX `idx_system_base_type` (`type`) USING BTREE,
  54. INDEX `idx_system_base_code` (`code`) USING BTREE,
  55. INDEX `idx_system_base_name` (`name`(191)) USING BTREE
  56. ) ENGINE = InnoDB
  57. AUTO_INCREMENT = 1
  58. CHARACTER SET = utf8mb4
  59. COLLATE = utf8mb4_unicode_ci COMMENT = '系统-字典'
  60. ROW_FORMAT = COMPACT;
  61. -- 权限表增加身份权限字段
  62. ALTER TABLE `system_user`
  63. ADD COLUMN `usertype` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '用户类型' AFTER `id`;
  64. -- 尝试创建系统文件数据表
  65. CREATE TABLE IF NOT EXISTS `system_file` (
  66. `id` bigint(20) NOT NULL AUTO_INCREMENT,
  67. `type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '上传类型',
  68. `hash` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '文件哈希',
  69. `name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '文件名称',
  70. `xext` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '文件后缀',
  71. `xurl` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '访问链接',
  72. `xkey` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '文件路径',
  73. `mime` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '文件类型',
  74. `size` bigint(20) NULL DEFAULT 0 COMMENT '文件大小',
  75. `uuid` bigint(20) NULL DEFAULT 0 COMMENT '用户编号',
  76. `isfast` tinyint(1) NULL DEFAULT 0 COMMENT '是否秒传',
  77. `issafe` tinyint(1) NULL DEFAULT 0 COMMENT '安全模式',
  78. `status` tinyint(1) NULL DEFAULT 1 COMMENT '上传状态(1悬空,2落地)',
  79. `create_at` datetime NULL DEFAULT NULL COMMENT '创建时间',
  80. `update_at` datetime NULL DEFAULT NULL COMMENT '更新时间',
  81. PRIMARY KEY (`id`) USING BTREE,
  82. INDEX `idx_system_file_type`(`type`) USING BTREE,
  83. INDEX `idx_system_file_hash`(`hash`) USING BTREE,
  84. INDEX `idx_system_file_uuid`(`uuid`) USING BTREE,
  85. INDEX `idx_system_file_xext`(`xext`) USING BTREE,
  86. INDEX `idx_system_file_status`(`status`) USING BTREE,
  87. INDEX `idx_system_file_issafe`(`issafe`) USING BTREE,
  88. INDEX `idx_system_file_isfast`(`isfast`) USING BTREE
  89. ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统-文件' ROW_FORMAT = COMPACT;
  90. SET FOREIGN_KEY_CHECKS = 1;