sequelize-auto icon indicating copy to clipboard operation
sequelize-auto copied to clipboard

Request: leave out 'defaultValue' from generated models (optional?)

Open mariusa opened this issue 3 years ago • 2 comments

We already have declared default values for some columns in db. When creating records, sequelize.create() doesn't specify columns if they are not set to a specific value, which is great. Columns will be set to defaults set in db.

Models generated by sequelize-auto read that default value and include it in model definition. This is undesired behavior. It also

  • introduces more complexity (leading to many issues with defaultValue: https://github.com/sequelize/sequelize-auto/search?q=defaultvalue&type=issues)
  • duplicates default value. Updating a column default value now also requires updating js models. We had bugs due to updating db defaults in production, but missed updating js models.

Please leave out 'defaultValue' from generated models, or have an option for it to be left out. Thanks!

mariusa avatar Jan 18 '22 18:01 mariusa

@steveschmitt What do you think? Now, every time we re-generate models we need to remove default values for everything to work properly.

mariusa avatar Feb 18 '22 09:02 mariusa

I got the same problem

AshaLiu avatar Aug 08 '22 19:08 AshaLiu