我似乎无法弄清楚如何使用 Sequelize 播种 ARRAY(ENUM)。当我通过我的应用程序注册用户时,我可以很好地创建一个新用户,但是当我在种子文件中使用 queryInterface.bulkInsert 时,我得到:
ERROR: column "roles" is of type "enum_Users_roles"[] but expression is of type text[]
这是我的代码:
return queryInterface.bulkInsert('Users', [
{
email: faker.internet.email(),
roles: ['user'],
password: "hash",
public_id: faker.random.uuid(),
created_at: new Date(),
updated_at: new Date()
}
]);
Run Code Online (Sandbox Code Playgroud)
这是我的用户迁移文件:
return queryInterface.createTable('Users', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
email: {
type: Sequelize.STRING,
allowNull: false
},
password: {
type: Sequelize.STRING,
allowNull: false
},
roles: {
type: Sequelize.ARRAY(Sequelize.ENUM({
values: ['user', 'setter', 'admin']
})),
allowNull: false …Run Code Online (Sandbox Code Playgroud)