Set defaultValue to todays date in a Sequelize migration

You need to use as a default value the MySQL function NOW().

So your column declaration should look like :

{ 
   type: Sequelize.DATEONLY,
   allowNull: false,
   defaultValue: Sequelize.NOW
}

Keep in mind that this will not populate the fields in your migration. They will be empty, since they were not created with sequelize.

Leave a Comment