dataSource.connector.query(
"ALTER TABLE Recipe ADD CONSTRAINT `fk_user_recipe`"
+ " FOREIGN KEY (`userId`)"
+ " REFERENCES `users` (`id`)"
+ " ON DELETE CASCADE"
, function(err){
.....
});
| Recipe | CREATE TABLE `Recipe` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(512) NOT NULL,
`description` varchar(512) DEFAULT NULL,
`servings` int(11) NOT NULL,
`preparingTime` int(11) NOT NULL,
`cookingTime` int(11) NOT NULL,
`createdAt` datetime DEFAULT NULL,
`userId` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `userId` (`userId`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 |
How do constraints?
I try:
But, mysql show table:
Help?