Define CHECK constraints at the Model level #16750
-
Hello, I would like to know if there is a way of defining a CHECK constraint at Model level. Currently, the only solution I know of is to add this type of constraint via the module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addConstraint("product", ["price"], {
type: "check",
name: "price_check",
fields: ["price"],
where: {
price: {
[Sequelize.Op.gt]: 0,
},
},
});
},
async down(queryInterface, Sequelize) {
await queryInterface.removeConstraint("product", "price_check");
},
}; What I want to do here is define the constraint at the Model level so that it is applied at the time of Nicolas |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
That is not currently supported: https://sequelize.org/docs/v7/models/validations-and-constraints/#check-constraints |
Beta Was this translation helpful? Give feedback.
That is not currently supported: https://sequelize.org/docs/v7/models/validations-and-constraints/#check-constraints