I created a table without the paranoid option, and i now want to change that table's definition to use paranoid.
I don't want to re-create the database since its already in production. how can i do that using migrations?
should i use addColumn with deletedAt and just add the paranoid definition to the model, or is there a better way?
I added the deletedAt field using migration like this:
"use strict";
module.exports = {
up: function(migration, DataTypes, done) {
// add altering commands here, calling 'done' when finished
migration.addColumn(
'mytablename',
'deletedAt',
{
type: DataTypes.DATE,
allowNull: true,
validate: {
}
}
);
done();
},
down: function(migration, DataTypes, done) {
// add reverting commands here, calling 'done' when finished
migration.removeColumn('mytablename', 'deletedAt');
done();
}
};
And added the configuration:
paranoid: true,
to my model
It seems to work.
Does anyone have a better solution?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With