Repository navigation
feat(query-interface): add support for defining composite foreign keys - #12456
Conversation
Only in the query interface. Extensive support for composite keys is the subject of sequelize#311; this is merely one step in the right direction.
Codecov Report
@@ Coverage Diff @@
## master #12456 +/- ##
==========================================
+ Coverage 96.44% 96.46% +0.02%
==========================================
Files 95 95
Lines 9192 9194 +2
==========================================
+ Hits 8865 8869 +4
+ Misses 327 325 -2
Continue to review full report at Codecov.
|
|
can you please explain how to use this ? |
|
This only changes the query interface to allow the creation of composite foreign keys. See addContraint options.fields in the docs: https://sequelize.org/master/class/lib/dialects/abstract/query-interface.js~QueryInterface.html#instance-method-addConstraint Note that the auto generated foreign key name may wind up too long for the database to accept. In that case simply use options.name to specify your own shorter name. |
|
I see that the problem has already been solved! How do I use it? |
|
@kf6kjg Can you open a PR for |
|
I've opened a PR to move this feature over to v6: #12867 |
Note: this commit was cherry-picked from a55c154
Hi @osvaldokalvaitir, sorry to take so long. You can use v6.4.0. |
Note: this commit was cherry-picked from a55c154
|
Looks like I missed the typescript file change. |
Only in the query interface. Extensive support for composite keys is the subject of #311; this is merely one step in the right direction.
Pull Request check-list
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
Added support for defining composite foreign keys using
queryInterface.addConstraint. To accomplish this thereferencesobject was extended to support either the existingfield:stringpair or the new keyfields: string[]pair - but not both.Test was added, documentation updated.
I've attached a patch for the typescript definitions, but the entire typescript typings seem to have been deleted from master in commit 042cd69.
sequelize_composite-foreign-keys_type-change.patch.txt