loading...

Discussion on: Modifying an existing sequelize migration

Collapse
vamshinandan profile image
vamshinandan

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

Collapse
anayooleru profile image
Anayo Oleru Author

Hi @vam, here is an example.

To add a Boolean column(Model):

is_activated: {
  type: DataTypes.BOOLEAN,
  defaultValue: false,
},

To insert a value into the column:

By default, it will always be False, but if you want to change it to true, pass true as the value. I mean a boolean true

example:

User.create({
is_activated: true
});

Collapse
anayooleru profile image
Anayo Oleru Author

Hi @Vam, here is an example.

To add a Boolean column(Model):

is_activated: {
  type: DataTypes.BOOLEAN,
  defaultValue: false,
},

To insert a value into the column:

By default, it will always be False, but if you want to change it to true, pass true as the value. I mean a boolean true

example:

User.create({
is_activated: true
});