I want to make a triple bond in Sequelize, as shown in the image below
Image
https://www.dropbox.com/s/v8bgsir2qqw6ccv/relationship%20.jpg
If I apply this code in sequelize
A.hasMany(B);
A.hasMany(C);
B.hasMany(C);
C.hasMany(A);
C.hasMany(B);
The resulting SQL code is as follows
CREATE TABLE IF NOT EXISTS `a_b_` (
PRIMARY KEY (`BId`,`AId`)
)
CREATE TABLE IF NOT EXISTS `a_c_` (
`CId` int(11) NOT NULL DEFAULT '0',
`AId` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`CId`,`AId`)
)
CREATE TABLE IF NOT EXISTS `b_c_` (
PRIMARY KEY (`CId`,`BId`)
)
But the result should be
CREATE TABLE IF NOT EXISTS `a_b_` (
PRIMARY KEY (`BId`,`AId`)
)
CREATE TABLE IF NOT EXISTS `a_b_c_` (
`AId` int(11) NOT NULL DEFAULT '0',
`BId` int(11) NOT NULL DEFAULT '0',
`CId` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`AId`,`BId`, 'CId')
)
I just can't create a table with pk (AId, BId, CId), someone can tell me where to go or what I can do.
Many thanks.
source
share