I am using sequelize
for building and migrating models to postgres. I am trying to add my attributes in an array of objects like this:
approvals: [ { id: { type: Sequelize.INTEGER }, isApproved: { type: Sequelize.BOOLEAN, allowNull: false, defaultValue: true, }, approvedById: { type: Sequelize.INTEGER, }, }, ],
and it's returning this error
ERROR: syntax error at or near "["
Full createTable()
call:
await queryInterface.createTable("leaves", {
id: {
type: Sequelize.INTEGER,
allowNull: false,
autoIncrement: true,
primaryKey: true,
},
emp_id: {
type: Sequelize.INTEGER,
},
from: {
type: Sequelize.DATE,
allowNull: false,
},
to: {
type: Sequelize.DATE,
allowNull: false,
},
desc: { type: Sequelize.TEXT },
approvals: [
{
id: { type: Sequelize.INTEGER },
isApproved: {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: true,
},
approvedById: {
type: Sequelize.INTEGER,
},
},
],
createdAt: Sequelize.DATE,
updatedAt: Sequelize.DATE,
});