for sequelize 6.3.0 version -
$ sequelize migration:create --name name_of_your_migration
this command is not working for create a migration file, then you can use-
$ sequelize migration:generate --name name_of_your_migration
Hi Hitarth1, you need to define a model as a paranoid. You can do that by passing theparanoid: true option when you're defining your model. And make sure timestamps is not false. Paranoid needs timestamp to work.
Hi i am having trouble adding boolean column, i am able to add the column but unable to insert the value into the column
Can you provide an example for it please
for sequelize 6.3.0 version -
$ sequelize migration:create --name name_of_your_migration
this command is not working for create a migration file, then you can use-
$ sequelize migration:generate --name name_of_your_migration
What if all I need to do is change the attribute name, like april, to something different?
Hi @phillipiscoding my bad, I didn't get notified about this comment.
To change the attribute name, you use the renameColumn method, this is an example below:
module.exports = {up: (queryInterface, Sequelize) => {
return Promise.all([
queryInterface.renameColumn('users', 'april', 'new_column_name'),
]);
}
down: (queryInterface, Sequelize) => {return Promise.all([
queryInterface.renameColumn('users', 'new_column_name', 'april'),
]);
},
}
How to perform soft delete in sequelize?
Hi Hitarth1, you need to define a model as a paranoid. You can do that by passing the
paranoid: trueoption when you're defining your model. And make suretimestampsis not false. Paranoid needs timestamp to work.don't forget to add deletedAt column
Thanks, your information. this help me a lot
Hi i am having trouble adding boolean column, i am able to add the column but unable to insert the value into the column
Can you provide an example for it please
Hi @vam, here is an example.
To add a Boolean column(Model):
To insert a value into the column:
By default, it will always be
False, but if you want to change it totrue, passtrueas the value. I mean a booleantrueexample:
User.create({
is_activated: true
});
Hi @Vam, here is an example.
To add a Boolean column(Model):
To insert a value into the column:
By default, it will always be
False, but if you want to change it totrue, passtrueas the value. I mean a booleantrueexample:
User.create({
is_activated: true
});
Thank you
Thank you. This was helpful. Keep it up