Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
figalex opened this issue Apr 2, 2014 · 2 comments
Closed

Comments

@figalex
Copy link

figalex commented Apr 2, 2014

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?

@figalex
Copy link
Author

figalex commented Apr 2, 2014

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

dxg added a commit that referenced this issue Apr 8, 2014
@dxg
Copy link
Collaborator

dxg commented Apr 8, 2014

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.

@dxg dxg closed this as completed Apr 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants