Skip to content

Foreign Key Constraits #1300

Closed
Closed

Description

@brunocascio

How do constraints?

I try:

dataSource.connector.query(
    "ALTER TABLE Recipe ADD CONSTRAINT `fk_user_recipe`"
    + " FOREIGN KEY (`userId`)"
    + " REFERENCES `users` (`id`)"
    + " ON DELETE CASCADE"
    , function(err){
      .....
  });

But, mysql show table:


| 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 |

Help?

Activity

  1. superkhau commented on Jul 7, 2015

    @superkhau
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions