Open cskiwi opened 3 years ago
For other people coming across this issue, I've found a hacky way to resolve this:
By placing the following exact key on the start column : @Unique('ClubMemberships_clubId_playerId_unique')
.
it combined the 2 unique instances and gave the wanted result.
If you are having issues finding the unique string:
node_modules/sequelize/lib/dialects/abstract/query-interface.js
console.log(tableName, options.uniqueKey)
below
if (model) {
options.uniqueKeys = options.uniqueKeys || model.uniqueKeys;
}
this will spit out each unique key when doing a sync
Versions
UPDATE: Just updated to latest version (v6) issue still persists
I'm submitting a ...
Actual behavior:
My many to many releationship is unique for a combination of 3 values (the 2 external id's and a date). However any configuration creates a unique constraint on the 2 ForeignKeys. So this doesn't allow inserts even if that 3th value is different
Error:
Expected behavior:
if you have
@PrimaryKey
on ForeignKeys and non-Foreignkeys, no creation of a constraint on those foreign keys. or a way to disable it.I tried numerous combinations of
@PrimaryKey
,@Unique
but non seem to give any correct resultSteps to reproduce:
Use the code below and
.sync({force: true})
Related code:
this generates:
If I would have the option to disable the automatic creation of the unique constraint I would be happy :)
note: I know I can remove that constraint via migrations, but this doesnt work for my tests