Skip to content

Commit

Permalink
Hotfix for issue sequelize#8984
Browse files Browse the repository at this point in the history
That's isn't the best way, but the fastest IMO.
  • Loading branch information
SzymonLisowiec committed Apr 16, 2021
1 parent 9f950cb commit bcf2bcb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,17 @@ class Model {
schema: globalOptions.schema
}, options);

Object.keys(attributes).forEach((attributeName) => {
const attribute = attributes[attributeName];
if (!attribute.unique) return;
options.indexes.push({
name: attributeName,
unique: true,
fields: [attributeName],
});
delete attribute.unique;
});

this.sequelize.runHooks('beforeDefine', attributes, options);

if (options.modelName !== this.name) {
Expand Down

0 comments on commit bcf2bcb

Please sign in to comment.