const User = sequelize.define('User', {
firstName: {
type: DataTypes.STRING,
allowNull: false,
unique : true,
}
}, {
tableName : 'user'
});
这里设置unique 为true
结果看到数据库中创建了两个UNIQUE KEY,这是什么情况???
CREATE TABLE user
(
id
int(11) NOT NULL AUTO_INCREMENT,
first_name
varchar(255) NOT NULL,
created_at
datetime NOT NULL,
updated_at
datetime NOT NULL,
PRIMARY KEY (id
),
UNIQUE KEY first_name
(first_name
),
UNIQUE KEY first_name_2
(first_name
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;