Skip to content

Model creates two primary keys with same column using Model.sync() function #484

Closed

Description

@figalex

I'm trying to generate my MySQL database tables from my node-orm models. Here's what I got:

var db = require('orm').db;

var User = db.define('user', {
    name: String,
    email: String,
    token: String
});

db.drop(function(){
    User.sync(function(){
    });
}); 

I let the User.sync() generates the User table in my database, I had successfully done this before but now my tables have two primary keys with the same column as you can see on the image:
screen shot 2014-04-01 at 8 34 52 pm

I've been getting "ER_OPERAND_COLUMNS: Operand should contain 1 column(s)" error everytime I want to add and instance of User to another model instance.

Does anyone know what can be causing this?

Activity

  1. figalex commented on Apr 2, 2014

    @figalex
    Author

    Also, tables that should have a foreign key doesn't have that foreign key, it is not being created.

  2. added a commit that references this issue on Apr 8, 2014
  3. dxg commented on Apr 8, 2014

    @dxg
    Collaborator

    It doesn't have two primary keys, it has two indexes for the one primary key which is wrong.. I just fixed it and released orm 2.1.5.

    As for foreign keys, ORM does not manage them at all.
    The migrations plugin can create foreign key constraints.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions