db-migrate / node-db-migrate

Database migration framework for node
Other
2.32k stars 361 forks source link

db-migrate up throw ER_PARSE_ERROR #128

Closed wxianfeng closed 11 years ago

wxianfeng commented 11 years ago

hi all my migrate file like this:

var dbm = require('db-migrate');
var type = dbm.dataType;

exports.up = function(db, callback) {
    db.createTable("users",{
        id: { type: 'int', primarykey: true, autoIncrement: true },
        email: 'string',
        created_at: 'datetime',
        updated_at: 'datetime'
    },callback)
};

exports.down = function(db, callback) {
};

when i run db-migrate up throw this error, ER_PARSE_ERROR

wxianfeng-2:fanqiang wangxianfeng$ db-migrate up
[ERROR] 20130914175153-create-table-users { [Error: ER_PARSE_ERROR: You have an error     in your SQL syntax; check the manual that corresponds to your MySQL server version          for the right syntax to use near '?)' at line 1]
   code: 'ER_PARSE_ERROR',
    errno: 1064,
    sqlState: '42000',
    index: 0 }

then, i see my mysql db, users table has created, but migrations table has no any data.

then i run db-migrate up agin, meet error as follow, tell me users already exists

wxianfeng-2:fanqiang wangxianfeng$ db-migrate up
[ERROR] Error: ER_TABLE_EXISTS_ERROR: Table 'users' already exists
    at Query.Sequence._packetToError (/data/nodejs/fanqiang/node_modules/db-migrate/node_modules/mysql/lib/protocol/sequences/Sequence.js:32:14)
    at Query.ErrorPacket (/data/nodejs/fanqiang/node_modules/db-migrate/node_modules/mysql/lib/protocol/sequences/Query.js:82:18)
    at Protocol._parsePacket (/data/nodejs/fanqiang/node_modules/db-migrate/node_modules/mysql/lib/protocol/Protocol.js:172:24)
    at Parser.write (/data/nodejs/fanqiang/node_modules/db-migrate/node_modules/mysql/lib/protocol/Parser.js:62:12)
    at Protocol.write (/data/nodejs/fanqiang/node_modules/db-migrate/node_modules/mysql/lib/protocol/Protocol.js:37:16)
    at Socket.ondata (stream.js:38:26)
    at Socket.EventEmitter.emit (events.js:126:20)
    at TCP.onread (net.js:396:14)

what problem? pls help me, thanks.

fschwiet commented 11 years ago

I'm having the same issue too, in one project. Another project uses db-migrate fine with the same initial migration. The working project had db-migrate version 0.5.4, the failing version had 0.6.0. I changed the failing project to use 0.5.4 and it started working without error.

kunklejr commented 11 years ago

Fixed in v0.6.1

fschwiet commented 11 years ago

Confirmed 0.6.1 is working as expected, thanks.

wxianfeng commented 11 years ago

test passed by 0.6.1, thanks MAN