Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequelize-cli how not to include timestamps while generating model and migration files?

Just following the sequelize doc ( http://docs.sequelizejs.com/manual/tutorial/migrations.html ), we can generate a model and a migration file using the sequelize-cli command like:

sequelize model:generate --name Users --attributes firstName:string,lastName:string,bio:text

but then, in the migration file, one can find two additional timestamps values that will be added to the DB:

  createdAt: {
    allowNull: false,
    type: Sequelize.DATE
  },
  updatedAt: {
    allowNull: false,
    type: Sequelize.DATE
  }

I know I can set timestamp: false and/or deleting these two entries manually, but it would be better to set an option while generating the model/migration files not to have these timestamps. Is there such a way?

like image 930
s.k Avatar asked Oct 28 '25 11:10

s.k


1 Answers

You can set the options in config.json as well. It works for all models.

"dialect": "mysql",
"logging": false,
"define": {
   "timestamps": true
}
like image 150
Shahzeb Khan Avatar answered Oct 31 '25 02:10

Shahzeb Khan



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!