text: 
  --
  -- Table structure for table `upms_dict_type`
  --
  
  drop table if exists `upms_dict_type`;
  create table upms_dict_type
  (
    dict_id          bigint(20)      not null auto_increment    comment '字典主键',
    dict_name        varchar(100)    default ''                 comment '字典名称',
    dict_type        varchar(100)    default ''                 comment '字典类型',
    status           char(1)         default '0'                comment '状态（0正常 1停用）',
    create_by        varchar(64)     default ''                 comment '创建者',
    create_time      datetime                                   comment '创建时间',
    update_by        varchar(64)     default ''                 comment '更新者',
    update_time      datetime                                   comment '更新时间',
    remark           varchar(500)    default null               comment '备注',
    primary key (dict_id),
    unique (dict_type)
  ) engine=innodb auto_increment=100 comment = '字典类型表';
  
  --
  -- Table structure for table `upms_dict_data`
  --
  
  drop table if exists `upms_dict_data`;
  create table upms_dict_data
  (
    dict_code        bigint(20)      not null auto_increment    comment '字典编码',
    dict_sort        int(4)          default 0                  comment '字典排序',
    dict_label       varchar(100)    default ''                 comment '字典标签',
    dict_value       varchar(100)    default ''                 comment '字典键值',
    dict_type        varchar(100)    default ''                 comment '字典类型',
    css_class        varchar(100)    default null               comment '样式属性（其他样式扩展）',
    list_class       varchar(100)    default null               comment '表格回显样式',
    is_default       char(1)         default 'N'                comment '是否默认（Y是 N否）',
    status           char(1)         default '0'                comment '状态（0正常 1停用）',
    create_by        varchar(64)     default ''                 comment '创建者',
    create_time      datetime                                   comment '创建时间',
    update_by        varchar(64)     default ''                 comment '更新者',
    update_time      datetime                                   comment '更新时间',
    remark           varchar(500)    default null               comment '备注',
    primary key (dict_code)
  ) engine=innodb auto_increment=100 comment = '字典数据表';
  
  --
  -- Table structure for table `upms_log`
  --
  
  DROP TABLE IF EXISTS `upms_log`;
  CREATE TABLE `upms_log` (
    `log_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号',
    `description` varchar(100) DEFAULT NULL COMMENT '操作描述',
    `username` varchar(20) DEFAULT NULL COMMENT '操作用户',
    `permissions` varchar(100) DEFAULT NULL COMMENT '权限值',
    `start_time` datetime DEFAULT NULL COMMENT '操作时间',
    `spend_time` int(11) DEFAULT NULL COMMENT '消耗时间',
    `base_path` varchar(500) DEFAULT NULL COMMENT '根路径',
    `uri` varchar(500) DEFAULT NULL COMMENT 'URI',
    `method` varchar(7) DEFAULT NULL COMMENT '请求类型',
    `parameter` mediumtext,
    `user_agent` varchar(500) DEFAULT NULL COMMENT '用户标识',
    `ip` varchar(30) DEFAULT NULL COMMENT 'IP地址',
    `result` tinyint(2) DEFAULT NULL COMMENT '响应状态',
    PRIMARY KEY (`log_id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=183 DEFAULT CHARSET=utf8 COMMENT='操作日志';
  
  --
  -- Table structure for table `upms_organization`
  --
  
  DROP TABLE IF EXISTS `upms_organization`;
  CREATE TABLE `upms_organization` (
    `organization_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '编号',
    `pid` int(10) DEFAULT NULL COMMENT '所属上级',
    `name` varchar(40) DEFAULT NULL COMMENT '组织名称',
    `description` varchar(500) DEFAULT NULL COMMENT '组织描述',
    `ctime` datetime DEFAULT NULL COMMENT '创建时间',
    PRIMARY KEY (`organization_id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8 COMMENT='组织';
  
  --
  -- Table structure for table `upms_permission`
  --
  
  DROP TABLE IF EXISTS `upms_permission`;
  /*!40101 SET @saved_cs_client     = @@character_set_client */;
  /*!50503 SET character_set_client = utf8mb4 */;
  CREATE TABLE `upms_permission` (
    `permission_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '编号',
    `system_id` int(10) unsigned NOT NULL COMMENT '所属系统',
    `pid` int(10) DEFAULT NULL COMMENT '所属上级',
    `name` varchar(20) NOT NULL COMMENT '名称',
    `type` tinyint(4) DEFAULT NULL COMMENT '类型(1:目录,2:菜单,3:按钮)',
    `permission_value` varchar(50) DEFAULT NULL COMMENT '权限值',
    `uri` varchar(100) DEFAULT NULL COMMENT '路径',
    `icon` varchar(50) DEFAULT NULL COMMENT '图标',
    `status` tinyint(4) DEFAULT NULL COMMENT '状态(0:禁止,1:正常)',
    `ctime` datetime DEFAULT NULL COMMENT '创建时间',
    `orders` bigint(20) NOT NULL COMMENT '排序',
    PRIMARY KEY (`permission_id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8 COMMENT='权限';
  
  --
  -- Table structure for table `upms_role`
  --
  
  DROP TABLE IF EXISTS `upms_role`;
  CREATE TABLE `upms_role` (
    `role_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '编号',
    `name` varchar(20) NOT NULL COMMENT '角色名称',
    `title` varchar(20) NOT NULL COMMENT '角色标题',
    `description` varchar(500) DEFAULT NULL COMMENT '角色描述',
    `ctime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `orders` bigint(20) NOT NULL COMMENT '排序',
    PRIMARY KEY (`role_id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8 COMMENT='角色';
  
  --
  -- Table structure for table `upms_role_permission`
  --
  
  DROP TABLE IF EXISTS `upms_role_permission`;
  CREATE TABLE `upms_role_permission` (
    `role_permission_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '编号',
    `role_id` int(10) unsigned NOT NULL COMMENT '角色编号',
    `permission_id` int(10) unsigned NOT NULL COMMENT '权限编号',
    PRIMARY KEY (`role_permission_id`),
    KEY `FK_urp_role_id` (`role_id`),
    KEY `FK_urp_permission_id` (`permission_id`),
    CONSTRAINT `FK_urp_permission_id` FOREIGN KEY (`permission_id`) REFERENCES `upms_permission` (`permission_id`),
    CONSTRAINT `FK_urp_role_id` FOREIGN KEY (`role_id`) REFERENCES `upms_role` (`role_id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=303 DEFAULT CHARSET=utf8 COMMENT='角色权限关联表';
  
  --
  -- Table structure for table `upms_system`
  --
  
  DROP TABLE IF EXISTS `upms_system`;
  CREATE TABLE `upms_system` (
    `system_id` bigint(10) unsigned NOT NULL COMMENT '编号',
    `icon` varchar(50) DEFAULT NULL COMMENT '图标',
    `banner` varchar(150) DEFAULT NULL COMMENT '背景',
    `theme` varchar(50) DEFAULT NULL COMMENT '主题',
    `basepath` varchar(100) NOT NULL COMMENT '根目录',
    `status` tinyint(4) DEFAULT NULL COMMENT '状态(-1:黑名单,1:正常)',
    `name` varchar(20) NOT NULL COMMENT '系统名称',
    `title` varchar(20) NOT NULL COMMENT '系统标题',
    `description` varchar(300) NOT NULL COMMENT '系统描述',
    `ctime` datetime DEFAULT NULL COMMENT '创建时间',
    `orders` bigint(20) NOT NULL COMMENT '排序',
    PRIMARY KEY (`system_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统';
  
  --
  -- Table structure for table `upms_user`
  --
  
  DROP TABLE IF EXISTS `upms_user`;
  CREATE TABLE `upms_user` (
    `user_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '编号',
    `username` varchar(20) NOT NULL COMMENT '帐号',
    `password` varchar(32) NOT NULL COMMENT '密码MD5(密码+盐)',
    `salt` varchar(32) DEFAULT NULL COMMENT '盐',
    `realname` varchar(20) NOT NULL COMMENT '姓名',
    `avatar` varchar(150) DEFAULT NULL COMMENT '头像',
    `phone` varchar(20) NOT NULL COMMENT '电话',
    `email` varchar(50) NOT NULL COMMENT '邮箱',
    `sex` tinyint(4) NOT NULL COMMENT '性别',
    `locked` tinyint(4) DEFAULT NULL COMMENT '状态(0:正常,1:锁定)',
    `ctime` datetime DEFAULT NULL COMMENT '创建时间',
    `organization_id` int(10) DEFAULT NULL COMMENT '所属组织机构',
    PRIMARY KEY (`user_id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8 COMMENT='用户';
  
  --
  -- Table structure for table `upms_user_organization`
  --
  
  DROP TABLE IF EXISTS `upms_user_organization`;
  CREATE TABLE `upms_user_organization` (
    `user_organization_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '编号',
    `user_id` int(10) unsigned NOT NULL COMMENT '用户编号',
    `organization_id` int(10) unsigned NOT NULL COMMENT '组织编号',
    PRIMARY KEY (`user_organization_id`),
    KEY `FK_uuo_user_id` (`user_id`),
    KEY `FK_uuo_organization_id` (`organization_id`),
    CONSTRAINT `FK_uuo_organization_id` FOREIGN KEY (`organization_id`) REFERENCES `upms_organization` (`organization_id`),
    CONSTRAINT `FK_uuo_user_id` FOREIGN KEY (`user_id`) REFERENCES `upms_user` (`user_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户组织关联表';
  
  --
  -- Table structure for table `upms_user_role`
  --
  
  DROP TABLE IF EXISTS `upms_user_role`;
  CREATE TABLE `upms_user_role` (
    `user_role_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '编号',
    `user_id` int(10) unsigned NOT NULL COMMENT '用户编号',
    `role_id` int(10) unsigned NOT NULL COMMENT '角色编号',
    PRIMARY KEY (`user_role_id`),
    KEY `FK_uur_user_id` (`user_id`),
    KEY `FK_uur_role_id` (`role_id`),
    CONSTRAINT `FK_uur_role_id_1` FOREIGN KEY (`role_id`) REFERENCES `upms_role` (`role_id`),
    CONSTRAINT `FK_uur_user_id` FOREIGN KEY (`user_id`) REFERENCES `upms_user` (`user_id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8 COMMENT='用户角色关联表';
  