One of my favorite utilities, sequelize, will automatically generate models from a database. However, it does not always recognize auto-increment functions on primary keys. This causes the model to sometimes generate wrong and causes errors when inserting. How can I search for the lines for the primary key and replace those lines with the correct lines (having the autoIncrement
flag)?
For example, this ...
id: {
type: DataTypes.INTEGER.UNSIGNED,
allowNull: false,
primaryKey: true
},
... needs to become, this ...
id: {
type: DataTypes.INTEGER.UNSIGNED,
autoIncrement: true,
primaryKey: true
},
I've tried using sed in the past but run into problems with the spacing, multi-line syntax, and remembering the command structure.