You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My sequelize version is '6.6.5'. When I use hasOne function to create a foreignKey in mariadb, I try to use foreignKey to customize my foreign key name. but it still will create a column named by sourceModel+primary key. here is my code:
CREATETABLEIF NOT EXISTS `students` (`id`INTEGERNOT NULL auto_increment , `name`VARCHAR(12) NOT NULL, `grade`VARCHAR(4), `school`VARCHAR(100), `tel`VARCHAR(11), `qq`VARCHAR(20), `email`VARCHAR(50), `addr`VARCHAR(100), `createdAt` DATETIME NOT NULL, `stuid`CHAR(36) BINARY, `UserId`CHAR(36) BINARY, PRIMARY KEY (`id`), FOREIGN KEY (`stuid`) REFERENCES`Users` (`id`) ON DELETESETNULLONUPDATE CASCADE, FOREIGN KEY (`UserId`) REFERENCES`Users` (`id`) ON DELETESETNULLONUPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8;
And I tried to pass a Object with name:stuid, but it's still don't work.
By the way, did I have some way to create a foreignKey and make this foreignKey be the target model's primaryKey. if I don't create a primary key for the model, it would default create a primary key named by id. But I want to use the column of another table to be this table's primaryKey
The text was updated successfully, but these errors were encountered:
My sequelize version is '6.6.5'. When I use hasOne function to create a foreignKey in mariadb, I try to use foreignKey to customize my foreign key name. but it still will create a column named by sourceModel+primary key. here is my code:
and here is the result
the sql query string is :
And I tried to pass a Object with
name:stuid
, but it's still don't work.By the way, did I have some way to create a foreignKey and make this foreignKey be the target model's primaryKey. if I don't create a primary key for the model, it would default create a primary key named by id. But I want to use the column of another table to be this table's primaryKey
The text was updated successfully, but these errors were encountered: