dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 377 forks source link

sync produces SQL error #545

Open maciejjankowski opened 10 years ago

maciejjankowski commented 10 years ago

When I first run the application it works okay, but after it terminates and I try running it again I get the following error:

(orm/postgres) CREATE TABLE "events" ("date" TIMESTAMP WITHOUT TIME ZONE, "etime" INTEGER, "id" INTEGER, "league" VARCHAR(255), "home" VARCHAR(255), "away" VARCHAR(255), "evStatus" VARCHAR(255), PRIMARY KEY ("id"))

c:\soket\db.js:33
error: relation "events" already exists

offending code:

exports.dbconnect = function(cb){
    orm.connect(connString, function (err, db) {
        if (err) throw err;

        Event = db.define("events",
            {
                date : {type: "date", time: true}
                , etime : {type   : "number", rational : false}
                , id : {type : "number", rational: false}
                , league : String
                , home : String
                , away : String
                , evStatus : String
            }, {} )
        .sync(function(err){ // line 33 is here
            if(err) throw err;