Hope you're well ! I have a question. How can I prevent the following error after a db reset (sync force true) please ?
SequelizeDatabaseError: type "enum_coverLists_supportingDocument" already exists
Here is what my model look like :
export const SUPPORTING_DOCUMENT = {
MEDIATION_FEES: 'MEDIATION_FEES',
LEGAL_COUNSEL_FEES: 'LEGAL_COUNSEL_FEES',
FILING_COMPLAINT: 'FILING_COMPLAINT'
};
export const TYPE = {
BUDGET: 'BUDGET',
QUANTITY: 'QUANTITY',
UNLIMITED: 'UNLIMITED'
};
const coverList = function (sequelize, Sequelize) {
const coverList = sequelize.define('coverList',
{
id: {
primaryKey: true,
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4
},
title: {
type: Sequelize.STRING,
allowNull: false
},
description: {
type: Sequelize.STRING,
allowNull: true
},
supportingDocument: {
type: Sequelize.ARRAY(Sequelize.ENUM({
values: [...Object.values(SUPPORTING_DOCUMENT)]
})),
validate: {
isIn: [...Object.values(SUPPORTING_DOCUMENT)],
},
allowNull: true
},
type: {
type: Sequelize.ENUM,
values: Object.values(TYPE),
validate: {
isIn: [Object.values(TYPE)],
},
allowNull: false
}
});
return coverList;
};
export default coverList;
Stack :
- Node.js
- PostgreSQL
- Sequelize
Thanks in advance for your help.