Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为啥建表语句的字段长度不一致 #9334

Closed
five111 opened this issue Oct 17, 2022 · 5 comments · Fixed by #9412
Closed

为啥建表语句的字段长度不一致 #9334

five111 opened this issue Oct 17, 2022 · 5 comments · Fixed by #9412
Assignees
Labels
area/Config kind/enhancement Category issues or prs related to enhancement.
Milestone

Comments

@five111
Copy link

five111 commented Oct 17, 2022

group_id这个字段在不同的表里字段长度不一致 当超过128是 rest接口插入会有问题
config_info表中长度是255

/******************************************/
/*   数据库全名 = nacos_config   */
/*   表名称 = config_info   */
/******************************************/
CREATE TABLE `config_info` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  `group_id` varchar(255) DEFAULT NULL,
  `content` longtext NOT NULL COMMENT 'content',
  `md5` varchar(32) DEFAULT NULL COMMENT 'md5',
  `gmt_create` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '创建时间',
  `gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '修改时间',
  `src_user` text COMMENT 'source user',
  `src_ip` varchar(20) DEFAULT NULL COMMENT 'source ip',
  `app_name` varchar(128) DEFAULT NULL,
  `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  `c_desc` varchar(256) DEFAULT NULL,
  `c_use` varchar(64) DEFAULT NULL,
  `effect` varchar(64) DEFAULT NULL,
  `type` varchar(64) DEFAULT NULL,
  `c_schema` text,
  `encrypted_data_key` text NOT NULL COMMENT '秘钥',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';

his_config_info中group_id长度又变成了128

/******************************************/
/*   数据库全名 = nacos_config   */
/*   表名称 = his_config_info   */
/******************************************/
CREATE TABLE `his_config_info` (
  `id` bigint(64) unsigned NOT NULL,
  `nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `data_id` varchar(255) NOT NULL,
  `group_id` varchar(128) NOT NULL,
  `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
  `content` longtext NOT NULL,
  `md5` varchar(32) DEFAULT NULL,
  `gmt_create` datetime NOT NULL DEFAULT '2010-05-05 00:00:00',
  `gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00',
  `src_user` text,
  `src_ip` varchar(20) DEFAULT NULL,
  `op_type` char(10) DEFAULT NULL,
  `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  `encrypted_data_key` text NOT NULL COMMENT '秘钥',
  PRIMARY KEY (`nid`),
  KEY `idx_gmt_create` (`gmt_create`),
  KEY `idx_gmt_modified` (`gmt_modified`),
  KEY `idx_did` (`data_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='多租户改造';

@wuchubuzai2018
Copy link
Contributor

应该是官方没太注意把,希望我可以提交这个PR,更新一下这个字段的值为255,可以吗社区的维护者们

@KomachiSion
Copy link
Collaborator

我觉得是改成128. 因为历史表啥的都是128. @shiyiyue1102 @realJackSun 确认一下,看是改成哪个长度

@KomachiSion KomachiSion added the kind/enhancement Category issues or prs related to enhancement. label Oct 19, 2022
@KomachiSion KomachiSion added this to the 2.2.0 milestone Oct 19, 2022
@KomachiSion
Copy link
Collaborator

KomachiSion commented Oct 26, 2022

我觉得应该全都改为128长度, 按照当前的表结构和逻辑, 如果group超过128, 插入历史表会失败, 配置表也就不会去插入,所以历史表的限制是优先于info表的。 @shiyiyue1102 确认一下。

@shiyiyue1102
Copy link
Collaborator

我觉得应该全都改为128长度, 按照当前的表结构和逻辑, 如果group超过128, 插入历史表会失败, 配置表也就不会去插入,所以历史表的限制是优先于info表的。 @shiyiyue1102 确认一下。

group_id长度应该是128

@KomachiSion
Copy link
Collaborator

@wuchubuzai2018 可以考虑提个pr 把长度统一成128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/Config kind/enhancement Category issues or prs related to enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants