Преглед изворни кода

update 确保更好的适配 多数据库 主键策略统一改为 雪花ID

疯狂的狮子li пре 4 година
родитељ
комит
ae376e121d
2 измењених фајлова са 38 додато и 46 уклоњено
  1. 1 7
      config/dev/application.yml
  2. 37 39
      sql/ry-cloud.sql

+ 1 - 7
config/dev/application.yml

@@ -231,16 +231,10 @@ mybatis-plus:
   global-config:
   global-config:
     # 是否打印 Logo banner
     # 是否打印 Logo banner
     banner: true
     banner: true
-    # 是否初始化 SqlRunner
-    enableSqlRunner: false
     dbConfig:
     dbConfig:
       # 主键类型
       # 主键类型
       # AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
       # AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
-      idType: AUTO
-      # 表名是否使用驼峰转下划线命名,只对表名生效
-      tableUnderline: true
-      # 大写命名,对表名和字段名均生效
-      capitalMode: false
+      idType: ASSIGN_ID
       # 逻辑已删除值
       # 逻辑已删除值
       logicDeleteValue: 2
       logicDeleteValue: 2
       # 逻辑未删除值
       # 逻辑未删除值

+ 37 - 39
sql/ry-cloud.sql

@@ -5,7 +5,7 @@ SET NAMES utf8mb4;
 -- ----------------------------
 -- ----------------------------
 drop table if exists sys_dept;
 drop table if exists sys_dept;
 create table sys_dept (
 create table sys_dept (
-  dept_id           bigint(20)      not null auto_increment    comment '部门id',
+  dept_id           bigint(20)      not null                   comment '部门id',
   parent_id         bigint(20)      default 0                  comment '父部门id',
   parent_id         bigint(20)      default 0                  comment '父部门id',
   ancestors         varchar(50)     default ''                 comment '祖级列表',
   ancestors         varchar(50)     default ''                 comment '祖级列表',
   dept_name         varchar(30)     default ''                 comment '部门名称',
   dept_name         varchar(30)     default ''                 comment '部门名称',
@@ -20,7 +20,7 @@ create table sys_dept (
   update_by         varchar(64)     default ''                 comment '更新者',
   update_by         varchar(64)     default ''                 comment '更新者',
   update_time       datetime                                   comment '更新时间',
   update_time       datetime                                   comment '更新时间',
   primary key (dept_id)
   primary key (dept_id)
-) engine=innodb auto_increment=200 comment = '部门表';
+) engine=innodb comment = '部门表';
 
 
 -- ----------------------------
 -- ----------------------------
 -- 初始化-部门表数据
 -- 初始化-部门表数据
@@ -42,7 +42,7 @@ insert into sys_dept values(109,  102, '0,100,102',  '财务部门',   2, '若
 -- ----------------------------
 -- ----------------------------
 drop table if exists sys_user;
 drop table if exists sys_user;
 create table sys_user (
 create table sys_user (
-  user_id           bigint(20)      not null auto_increment    comment '用户ID',
+  user_id           bigint(20)      not null                   comment '用户ID',
   dept_id           bigint(20)      default null               comment '部门ID',
   dept_id           bigint(20)      default null               comment '部门ID',
   user_name         varchar(30)     not null                   comment '用户账号',
   user_name         varchar(30)     not null                   comment '用户账号',
   nick_name         varchar(30)     not null                   comment '用户昵称',
   nick_name         varchar(30)     not null                   comment '用户昵称',
@@ -62,7 +62,7 @@ create table sys_user (
   update_time       datetime                                   comment '更新时间',
   update_time       datetime                                   comment '更新时间',
   remark            varchar(500)    default null               comment '备注',
   remark            varchar(500)    default null               comment '备注',
   primary key (user_id)
   primary key (user_id)
-) engine=innodb auto_increment=100 comment = '用户信息表';
+) engine=innodb comment = '用户信息表';
 
 
 -- ----------------------------
 -- ----------------------------
 -- 初始化-用户信息表数据
 -- 初始化-用户信息表数据
@@ -77,7 +77,7 @@ insert into sys_user values(2,  105, 'lionli', '疯狂的狮子Li', 'sys_user',
 drop table if exists sys_post;
 drop table if exists sys_post;
 create table sys_post
 create table sys_post
 (
 (
-  post_id       bigint(20)      not null auto_increment    comment '岗位ID',
+  post_id       bigint(20)      not null                   comment '岗位ID',
   post_code     varchar(64)     not null                   comment '岗位编码',
   post_code     varchar(64)     not null                   comment '岗位编码',
   post_name     varchar(50)     not null                   comment '岗位名称',
   post_name     varchar(50)     not null                   comment '岗位名称',
   post_sort     int(4)          not null                   comment '显示顺序',
   post_sort     int(4)          not null                   comment '显示顺序',
@@ -104,7 +104,7 @@ insert into sys_post values(4, 'user', '普通员工',  4, '0', 'admin', sysdate
 -- ----------------------------
 -- ----------------------------
 drop table if exists sys_role;
 drop table if exists sys_role;
 create table sys_role (
 create table sys_role (
-  role_id              bigint(20)      not null auto_increment    comment '角色ID',
+  role_id              bigint(20)      not null                   comment '角色ID',
   role_name            varchar(30)     not null                   comment '角色名称',
   role_name            varchar(30)     not null                   comment '角色名称',
   role_key             varchar(100)    not null                   comment '角色权限字符串',
   role_key             varchar(100)    not null                   comment '角色权限字符串',
   role_sort            int(4)          not null                   comment '显示顺序',
   role_sort            int(4)          not null                   comment '显示顺序',
@@ -119,7 +119,7 @@ create table sys_role (
   update_time          datetime                                   comment '更新时间',
   update_time          datetime                                   comment '更新时间',
   remark               varchar(500)    default null               comment '备注',
   remark               varchar(500)    default null               comment '备注',
   primary key (role_id)
   primary key (role_id)
-) engine=innodb auto_increment=100 comment = '角色信息表';
+) engine=innodb comment = '角色信息表';
 
 
 -- ----------------------------
 -- ----------------------------
 -- 初始化-角色信息表数据
 -- 初始化-角色信息表数据
@@ -133,7 +133,7 @@ insert into sys_role values('2', '普通角色',    'common', 2, 2, 1, 1, '0', '
 -- ----------------------------
 -- ----------------------------
 drop table if exists sys_menu;
 drop table if exists sys_menu;
 create table sys_menu (
 create table sys_menu (
-  menu_id           bigint(20)      not null auto_increment    comment '菜单ID',
+  menu_id           bigint(20)      not null                   comment '菜单ID',
   menu_name         varchar(50)     not null                   comment '菜单名称',
   menu_name         varchar(50)     not null                   comment '菜单名称',
   parent_id         bigint(20)      default 0                  comment '父菜单ID',
   parent_id         bigint(20)      default 0                  comment '父菜单ID',
   order_num         int(4)          default 0                  comment '显示顺序',
   order_num         int(4)          default 0                  comment '显示顺序',
@@ -153,7 +153,7 @@ create table sys_menu (
   update_time       datetime                                   comment '更新时间',
   update_time       datetime                                   comment '更新时间',
   remark            varchar(500)    default ''                 comment '备注',
   remark            varchar(500)    default ''                 comment '备注',
   primary key (menu_id)
   primary key (menu_id)
-) engine=innodb auto_increment=2000 comment = '菜单权限表';
+) engine=innodb comment = '菜单权限表';
 
 
 -- ----------------------------
 -- ----------------------------
 -- 初始化-菜单信息表数据
 -- 初始化-菜单信息表数据
@@ -417,7 +417,7 @@ insert into sys_user_post values ('2', '2');
 -- ----------------------------
 -- ----------------------------
 drop table if exists sys_oper_log;
 drop table if exists sys_oper_log;
 create table sys_oper_log (
 create table sys_oper_log (
-  oper_id           bigint(20)      not null auto_increment    comment '日志主键',
+  oper_id           bigint(20)      not null                   comment '日志主键',
   title             varchar(50)     default ''                 comment '模块标题',
   title             varchar(50)     default ''                 comment '模块标题',
   business_type     int(2)          default 0                  comment '业务类型(0其它 1新增 2修改 3删除)',
   business_type     int(2)          default 0                  comment '业务类型(0其它 1新增 2修改 3删除)',
   method            varchar(100)    default ''                 comment '方法名称',
   method            varchar(100)    default ''                 comment '方法名称',
@@ -434,7 +434,7 @@ create table sys_oper_log (
   error_msg         varchar(2000)   default ''                 comment '错误消息',
   error_msg         varchar(2000)   default ''                 comment '错误消息',
   oper_time         datetime                                   comment '操作时间',
   oper_time         datetime                                   comment '操作时间',
   primary key (oper_id)
   primary key (oper_id)
-) engine=innodb auto_increment=100 comment = '操作日志记录';
+) engine=innodb comment = '操作日志记录';
 
 
 
 
 -- ----------------------------
 -- ----------------------------
@@ -443,7 +443,7 @@ create table sys_oper_log (
 drop table if exists sys_dict_type;
 drop table if exists sys_dict_type;
 create table sys_dict_type
 create table sys_dict_type
 (
 (
-  dict_id          bigint(20)      not null auto_increment    comment '字典主键',
+  dict_id          bigint(20)      not null                   comment '字典主键',
   dict_name        varchar(100)    default ''                 comment '字典名称',
   dict_name        varchar(100)    default ''                 comment '字典名称',
   dict_type        varchar(100)    default ''                 comment '字典类型',
   dict_type        varchar(100)    default ''                 comment '字典类型',
   status           char(1)         default '0'                comment '状态(0正常 1停用)',
   status           char(1)         default '0'                comment '状态(0正常 1停用)',
@@ -454,7 +454,7 @@ create table sys_dict_type
   remark           varchar(500)    default null               comment '备注',
   remark           varchar(500)    default null               comment '备注',
   primary key (dict_id),
   primary key (dict_id),
   unique (dict_type)
   unique (dict_type)
-) engine=innodb auto_increment=100 comment = '字典类型表';
+) engine=innodb comment = '字典类型表';
 
 
 insert into sys_dict_type values(1,  '用户性别', 'sys_user_sex',        '0', 'admin', sysdate(), '', null, '用户性别列表');
 insert into sys_dict_type values(1,  '用户性别', 'sys_user_sex',        '0', 'admin', sysdate(), '', null, '用户性别列表');
 insert into sys_dict_type values(2,  '菜单状态', 'sys_show_hide',       '0', 'admin', sysdate(), '', null, '菜单状态列表');
 insert into sys_dict_type values(2,  '菜单状态', 'sys_show_hide',       '0', 'admin', sysdate(), '', null, '菜单状态列表');
@@ -473,7 +473,7 @@ insert into sys_dict_type values(10, '系统状态', 'sys_common_status',   '0',
 drop table if exists sys_dict_data;
 drop table if exists sys_dict_data;
 create table sys_dict_data
 create table sys_dict_data
 (
 (
-  dict_code        bigint(20)      not null auto_increment    comment '字典编码',
+  dict_code        bigint(20)      not null                   comment '字典编码',
   dict_sort        int(4)          default 0                  comment '字典排序',
   dict_sort        int(4)          default 0                  comment '字典排序',
   dict_label       varchar(100)    default ''                 comment '字典标签',
   dict_label       varchar(100)    default ''                 comment '字典标签',
   dict_value       varchar(100)    default ''                 comment '字典键值',
   dict_value       varchar(100)    default ''                 comment '字典键值',
@@ -488,7 +488,7 @@ create table sys_dict_data
   update_time      datetime                                   comment '更新时间',
   update_time      datetime                                   comment '更新时间',
   remark           varchar(500)    default null               comment '备注',
   remark           varchar(500)    default null               comment '备注',
   primary key (dict_code)
   primary key (dict_code)
-) engine=innodb auto_increment=100 comment = '字典数据表';
+) engine=innodb comment = '字典数据表';
 
 
 insert into sys_dict_data values(1,  1,  '男',       '0',       'sys_user_sex',        '',   '',        'Y', '0', 'admin', sysdate(), '', null, '性别男');
 insert into sys_dict_data values(1,  1,  '男',       '0',       'sys_user_sex',        '',   '',        'Y', '0', 'admin', sysdate(), '', null, '性别男');
 insert into sys_dict_data values(2,  2,  '女',       '1',       'sys_user_sex',        '',   '',        'N', '0', 'admin', sysdate(), '', null, '性别女');
 insert into sys_dict_data values(2,  2,  '女',       '1',       'sys_user_sex',        '',   '',        'N', '0', 'admin', sysdate(), '', null, '性别女');
@@ -525,7 +525,7 @@ insert into sys_dict_data values(28, 2,  '失败',     '1',       'sys_common_st
 -- ----------------------------
 -- ----------------------------
 drop table if exists sys_config;
 drop table if exists sys_config;
 create table sys_config (
 create table sys_config (
-  config_id         int(5)          not null auto_increment    comment '参数主键',
+  config_id         int(5)          not null                   comment '参数主键',
   config_name       varchar(100)    default ''                 comment '参数名称',
   config_name       varchar(100)    default ''                 comment '参数名称',
   config_key        varchar(100)    default ''                 comment '参数键名',
   config_key        varchar(100)    default ''                 comment '参数键名',
   config_value      varchar(500)    default ''                 comment '参数键值',
   config_value      varchar(500)    default ''                 comment '参数键值',
@@ -536,7 +536,7 @@ create table sys_config (
   update_time       datetime                                   comment '更新时间',
   update_time       datetime                                   comment '更新时间',
   remark            varchar(500)    default null               comment '备注',
   remark            varchar(500)    default null               comment '备注',
   primary key (config_id)
   primary key (config_id)
-) engine=innodb auto_increment=100 comment = '参数配置表';
+) engine=innodb comment = '参数配置表';
 
 
 insert into sys_config values(1, '主框架页-默认皮肤样式名称',     'sys.index.skinName',       'skin-blue',     'Y', 'admin', sysdate(), '', null, '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow' );
 insert into sys_config values(1, '主框架页-默认皮肤样式名称',     'sys.index.skinName',       'skin-blue',     'Y', 'admin', sysdate(), '', null, '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow' );
 insert into sys_config values(2, '用户管理-账号初始密码',         'sys.user.initPassword',    '123456',        'Y', 'admin', sysdate(), '', null, '初始化密码 123456' );
 insert into sys_config values(2, '用户管理-账号初始密码',         'sys.user.initPassword',    '123456',        'Y', 'admin', sysdate(), '', null, '初始化密码 123456' );
@@ -549,21 +549,21 @@ insert into sys_config values(11, 'OSS预览列表资源开关',        'sys.oss
 -- ----------------------------
 -- ----------------------------
 drop table if exists sys_logininfor;
 drop table if exists sys_logininfor;
 create table sys_logininfor (
 create table sys_logininfor (
-  info_id        bigint(20)     not null auto_increment   comment '访问ID',
+  info_id        bigint(20)     not null                  comment '访问ID',
   user_name      varchar(50)    default ''                comment '用户账号',
   user_name      varchar(50)    default ''                comment '用户账号',
   ipaddr         varchar(128)   default ''                comment '登录IP地址',
   ipaddr         varchar(128)   default ''                comment '登录IP地址',
   status         char(1)        default '0'               comment '登录状态(0成功 1失败)',
   status         char(1)        default '0'               comment '登录状态(0成功 1失败)',
   msg            varchar(255)   default ''                comment '提示信息',
   msg            varchar(255)   default ''                comment '提示信息',
   access_time    datetime                                 comment '访问时间',
   access_time    datetime                                 comment '访问时间',
   primary key (info_id)
   primary key (info_id)
-) engine=innodb auto_increment=100 comment = '系统访问记录';
+) engine=innodb comment = '系统访问记录';
 
 
 -- ----------------------------
 -- ----------------------------
 -- 17、通知公告表
 -- 17、通知公告表
 -- ----------------------------
 -- ----------------------------
 drop table if exists sys_notice;
 drop table if exists sys_notice;
 create table sys_notice (
 create table sys_notice (
-  notice_id         int(4)          not null auto_increment    comment '公告ID',
+  notice_id         int(4)          not null                   comment '公告ID',
   notice_title      varchar(50)     not null                   comment '公告标题',
   notice_title      varchar(50)     not null                   comment '公告标题',
   notice_type       char(1)         not null                   comment '公告类型(1通知 2公告)',
   notice_type       char(1)         not null                   comment '公告类型(1通知 2公告)',
   notice_content    longblob        default null               comment '公告内容',
   notice_content    longblob        default null               comment '公告内容',
@@ -574,7 +574,7 @@ create table sys_notice (
   update_time       datetime                                   comment '更新时间',
   update_time       datetime                                   comment '更新时间',
   remark            varchar(255)    default null               comment '备注',
   remark            varchar(255)    default null               comment '备注',
   primary key (notice_id)
   primary key (notice_id)
-) engine=innodb auto_increment=10 comment = '通知公告表';
+) engine=innodb comment = '通知公告表';
 
 
 -- ----------------------------
 -- ----------------------------
 -- 初始化-公告信息表数据
 -- 初始化-公告信息表数据
@@ -587,7 +587,7 @@ insert into sys_notice values('2', '维护通知:2018-07-01 若依系统凌晨
 -- ----------------------------
 -- ----------------------------
 drop table if exists sys_oss;
 drop table if exists sys_oss;
 create table sys_oss (
 create table sys_oss (
-  oss_id          bigint(20)        not null auto_increment    comment '对象存储主键',
+  oss_id          bigint(20)        not null                   comment '对象存储主键',
   file_name       varchar(255)      not null default ''        comment '文件名',
   file_name       varchar(255)      not null default ''        comment '文件名',
   original_name   varchar(255)      not null default ''        comment '原名',
   original_name   varchar(255)      not null default ''        comment '原名',
   file_suffix     varchar(10)       not null default ''        comment '文件后缀名',
   file_suffix     varchar(10)       not null default ''        comment '文件后缀名',
@@ -605,7 +605,7 @@ create table sys_oss (
 -- ----------------------------
 -- ----------------------------
 drop table if exists sys_oss_config;
 drop table if exists sys_oss_config;
 create table sys_oss_config (
 create table sys_oss_config (
-  oss_config_id   bigint(20)         not null auto_increment    comment '主建',
+  oss_config_id   bigint(20)         not null                   comment '主建',
   config_key      varchar(255)       not null default ''        comment '配置key',
   config_key      varchar(255)       not null default ''        comment '配置key',
   access_key      varchar(255)       default ''                 comment 'accessKey',
   access_key      varchar(255)       default ''                 comment 'accessKey',
   secret_key      varchar(255)       default ''                 comment '秘钥',
   secret_key      varchar(255)       default ''                 comment '秘钥',
@@ -634,7 +634,7 @@ insert into sys_oss_config values (4, 'qcloud', 'XXXXXXXXXXXXXXX',  'XXXXXXXXXXX
 -- ----------------------------
 -- ----------------------------
 drop table if exists gen_table;
 drop table if exists gen_table;
 create table gen_table (
 create table gen_table (
-  table_id          bigint(20)      not null auto_increment    comment '编号',
+  table_id          bigint(20)      not null                   comment '编号',
   table_name        varchar(200)    default ''                 comment '表名称',
   table_name        varchar(200)    default ''                 comment '表名称',
   table_comment     varchar(500)    default ''                 comment '表描述',
   table_comment     varchar(500)    default ''                 comment '表描述',
   sub_table_name    varchar(64)     default null               comment '关联子表的表名',
   sub_table_name    varchar(64)     default null               comment '关联子表的表名',
@@ -655,7 +655,7 @@ create table gen_table (
   update_time       datetime                                   comment '更新时间',
   update_time       datetime                                   comment '更新时间',
   remark            varchar(500)    default null               comment '备注',
   remark            varchar(500)    default null               comment '备注',
   primary key (table_id)
   primary key (table_id)
-) engine=innodb auto_increment=1 comment = '代码生成业务表';
+) engine=innodb comment = '代码生成业务表';
 
 
 
 
 -- ----------------------------
 -- ----------------------------
@@ -663,7 +663,7 @@ create table gen_table (
 -- ----------------------------
 -- ----------------------------
 drop table if exists gen_table_column;
 drop table if exists gen_table_column;
 create table gen_table_column (
 create table gen_table_column (
-  column_id         bigint(20)      not null auto_increment    comment '编号',
+  column_id         bigint(20)      not null                   comment '编号',
   table_id          varchar(64)                                comment '归属表编号',
   table_id          varchar(64)                                comment '归属表编号',
   column_name       varchar(200)                               comment '列名称',
   column_name       varchar(200)                               comment '列名称',
   column_comment    varchar(500)                               comment '列描述',
   column_comment    varchar(500)                               comment '列描述',
@@ -686,19 +686,17 @@ create table gen_table_column (
   update_by         varchar(64)     default ''                 comment '更新者',
   update_by         varchar(64)     default ''                 comment '更新者',
   update_time       datetime                                   comment '更新时间',
   update_time       datetime                                   comment '更新时间',
   primary key (column_id)
   primary key (column_id)
-) engine=innodb auto_increment=1 comment = '代码生成业务表字段';
+) engine=innodb comment = '代码生成业务表字段';
 
 
 -- for AT mode you must to init this sql for you business database. the seata server not need it.
 -- for AT mode you must to init this sql for you business database. the seata server not need it.
-CREATE TABLE IF NOT EXISTS `undo_log`
+CREATE TABLE IF NOT EXISTS undo_log
 (
 (
-    `branch_id`     BIGINT(20)   NOT NULL COMMENT 'branch transaction id',
-    `xid`           VARCHAR(100) NOT NULL COMMENT 'global transaction id',
-    `context`       VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
-    `rollback_info` LONGBLOB     NOT NULL COMMENT 'rollback info',
-    `log_status`    INT(11)      NOT NULL COMMENT '0:normal status,1:defense status',
-    `log_created`   DATETIME(6)  NOT NULL COMMENT 'create datetime',
-    `log_modified`  DATETIME(6)  NOT NULL COMMENT 'modify datetime',
-    UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
-) ENGINE = InnoDB
-    AUTO_INCREMENT = 1
-    DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
+    branch_id     BIGINT(20)   NOT NULL COMMENT 'branch transaction id',
+    xid           VARCHAR(100) NOT NULL COMMENT 'global transaction id',
+    context       VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
+    rollback_info LONGBLOB     NOT NULL COMMENT 'rollback info',
+    log_status    INT(11)      NOT NULL COMMENT '0:normal status,1:defense status',
+    log_created   DATETIME(6)  NOT NULL COMMENT 'create datetime',
+    log_modified  DATETIME(6)  NOT NULL COMMENT 'modify datetime',
+    UNIQUE KEY ux_undo_log (xid, branch_id)
+) ENGINE = InnoDB COMMENT ='AT transaction mode undo table';