I need to create Trigger on one of my Table using Sequelize Migration in Node and PostgreSQL. I haven't found enough documentation around it.
Currently I am using sequelize version 3.23 and quite familiar with PostgreSQL triggers, but not able to find anything around migration of triggers.
I am following docs provided on sequelize site related to migrations:
module.exports = {
up: function(queryInterface, Sequelize) {
// create trigger
},
down: function(queryInterface, Sequelize) {
// remove trigger
}
}
Hope I get quick resolution around it.. Thanks in Advance :)
You can add the triggers to your models, they're not called triggers in your sequelize models though they're called
Hooks
.Using hooks is probably a better idea since you can integrate them with your models and create actual model instances but if you really want to use postgres triggers then you can use
Sequelize.query()
like so: