node.jssequelize.jsdatabase-migrationsequelize-cli

How to removeConstraint defaultValue in Sequelize


I'm trying to write a migration in Sequelize and want to remove the defaultValue constraint. What is the proper syntax? I've tried both of the following:

return queryInterface.removeConstraint('Table', 'table_columnName_default')
return queryInterface.removeConstraint('Table', 'columnName_default')

Solution

  • Can you please try to use

    return queryInterface.changeColumn('Table', 'attributeName', {
        defaultValue: null,
        allowNull: true,
    });
    

    http://docs.sequelizejs.com/class/lib/query-interface.js~QueryInterface.html#instance-method-changeColumn