Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequelize is not updated when I added new column in table

I cannot convince why my sequelize models is not updated when I add new column in table.

I've added new column 'status INTEGER' in my table and updated as follow in Models of my table in sequelize. When I retrieve value from my table, it coming nothing.

enter image description here

            },
            status: {
                type: DataTypes.INTEGER,
                default: 0
            }

Please help me how to solve that issue. And even I've run migration as follow.

module.exports = {
    up: function (migration, DataTypes, done) {

        function addDisabledColumn() {
            return migration.addColumn('applications', 'status',
                {
                    type: DataTypes.INTEGER,
                    default: 0
                }
            )
        }

        addDisabledColumn().then(function () {
            done();
        }, function (err) {
            done(err);
        });

    },
    down: function (migration, DataTypes, done) {
        done()
    }
};
like image 455
PPShein Avatar asked Nov 15 '25 04:11

PPShein


1 Answers

you need to resync the table for changes to take effect try sequalize.sync({force:true}) hope it helps :)

like image 86
FastTurtle Avatar answered Nov 17 '25 19:11

FastTurtle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!