Sails.js 使用sails mysql在SailsJS 1.0中输入ER_-TOO_-LONG_键
当我尝试提升帆时,帆出现了这个错误:Sails.js 使用sails mysql在SailsJS 1.0中输入ER_-TOO_-LONG_键,sails.js,Sails.js,当我尝试提升帆时,帆出现了这个错误: info: ·• Auto-migrating... (drop) error: A hook (`orm`) failed to load! error: error: Error: ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes 我现在只有一个型号: module.exports = { datastore: 'default', ta
info: ·• Auto-migrating... (drop)
error: A hook (`orm`) failed to load!
error:
error: Error: ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes
我现在只有一个型号:
module.exports = {
datastore: 'default',
tableName: 'sci_user',
attributes: {
email: {
type: 'string',
required: true,
unique: true
},
password: {
type: 'string',
required: true
}
}
它非常简单,我是从文档中得到的。我不明白。这似乎是因为
的独特性:true
这是由多种因素组合而成的,但最相关的一个因素是sails mysql
目前默认为字符串属性使用utf8mb4
字符集,以允许使用表情符号和其他扩展字符。我们正在开发一个补丁,使其可配置,而不是默认设置,但与此同时,最快的解决方法是直接为属性声明columnType
:
module.exports={
datastore: 'default',
tableName: 'sci_user',
attributes: {
email: {
type: 'string',
required: true,
unique: true,
columnType: 'varchar'
},
password: {
type: 'string',
required: true,
columnType: 'varchar'
}
}
如果你处理了unique:true行,它解决了问题吗?是的,确实解决了问题。你可以尝试一些解决方法,因为错误抛出了ER_太长的键。1.更新你的mysql 2.在mysql
email
列排序规则类型3中的utf8/拉丁基之间切换。编辑email
列排序规则类型3.编辑email
的长度使用mysql控制台/phpmyadmin