I'm using Node Express with Sequelize and I want to set the defaultValue for the column "date" in the database to todays date. I tried with the following migration, but it didn't work, as it set the default date to be the same date as when I ran the migration. I want it to be set to the same date as when the row is created.
module.exports = {
up: function (queryInterface, Sequelize) {
return queryInterface.addColumn(
'Todos',
'date',
{
type: Sequelize.DATEONLY,
allowNull: false,
defaultValue: new Date()
}
)
},
I can't understand how that would work.
Sequelize.fn('now')
– Erasmoerasmus