1089 (HY000): Incorrect prefix key; the used key part isn’t a string, the used length is longer than the key part, or the storage engine doesn’t support unique prefix keys.
1069: Too many keys specified; max 64 keys allowed.
使用以下方法解决:
1 2 3 4 5 6 7 8 9 10
# 生成删除所有索引用的语句 SELECT CONCAT('ALTER TABLE `',i.TABLE_NAME,'` DROP INDEX `',i.INDEX_NAME,'` ;') FROM INFORMATION_SCHEMA.STATISTICS i WHERE TABLE_SCHEMA = 'dbname' AND i.INDEX_NAME <> 'PRIMARY';
1071 (42000): Specified key was too long; max key length is 3072 bytes.
一看,索引的字段包含4个varchar(255)+两个text,直接长度爆炸
尝试多种解决方案未果,直接删库跑路删除该索引
转换成功了,但是并没有什么卵用
1 2 3 4 5 6 7 8 9 10 11
2021/06/20 10:03:31 ...om/urfave/cli/app.go:524:HandleAction() [W] Table reaction column id db type is INT(11), struct type is BIGINT(20) 2021/06/20 10:03:31 ...om/urfave/cli/app.go:524:HandleAction() [W] Table reaction column type db type is TEXT, struct type is VARCHAR(255) 2021/06/20 10:03:31 ...om/urfave/cli/app.go:524:HandleAction() [W] Table reaction column issue_id db type is INT(11), struct type is BIGINT(20) 2021/06/20 10:03:31 ...om/urfave/cli/app.go:524:HandleAction() [W] Table reaction column comment_id db type is INT(11), struct type is BIGINT(20) 2021/06/20 10:03:31 ...om/urfave/cli/app.go:524:HandleAction() [W] Table reaction column user_id db type is INT(11), struct type is BIGINT(20) 2021/06/20 10:03:31 ...om/urfave/cli/app.go:524:HandleAction() [W] Table reaction column original_author_id db type is INT(11), struct type is BIGINT(20) 2021/06/20 10:03:31 ...om/urfave/cli/app.go:524:HandleAction() [W] Table reaction Column original_author_id db default is , struct default is 0 2021/06/20 10:03:31 ...om/urfave/cli/app.go:524:HandleAction() [W] Table reaction column original_author db type is TEXT, struct type is VARCHAR(255) 2021/06/20 10:03:31 ...om/urfave/cli/app.go:524:HandleAction() [W] Table reaction column created_unix db type is INT(11), struct type is BIGINT(20) 2021/06/20 10:03:31 models/models.go:231:NewEngine() [I] [SQL] CREATE UNIQUE INDEX `UQE_reaction_s` ON `reaction` (`type`,`issue_id`,`comment_id`,`user_id`,`original_author_id`,`original_author`) [] - 6.427735ms 2021/06/20 10:03:31 routers/init.go:102:GlobalInit() [F] ORM engine initialization failed: sync database struct error: Error 1170: BLOB/TEXT column 'type' used in key specification without a key length