-
-
Notifications
You must be signed in to change notification settings - Fork 361
Description
Hello!
After browsing the issues, I found a similar issue posted a couple of days ago (#407). However, this one's different, as it has to do with postgres (psql).
It seems that I cannot add a column while referencing it to be a primary key while using addColumn
. To make matters more precise, the error is:
[ERROR] TypeError: Cannot read property 'emitPrimaryKey' of undefined
at Class.Base.extend.createColumnConstraint (.../node_modules/db-migrate/lib/driver/pg.js:200:39)
at Class.Base.extend.createColumnDef (.../node_modules/db-migrate/lib/driver/pg.js:29:31)
at Class.module.exports.Class.extend.addColumn (.../node_modules/db-migrate/lib/driver/base.js:178:20)
at exports.down (.../migrations/20160829085748-myMigration.js:16:8)
at Migration._down (.../node_modules/db-migrate/lib/migration.js:176:34)
And the trace goes on. However, I debugged it a bit, and found the error to be the non-passing of objects, therefore resulting on the undefined. Step by step:
My migration:
db.addColumn('table_name', 'column_name', { type: type.STRING, primaryKey: true }, callback);
Where the error occurs:
node-db-migrate/lib/driver/pg.js
Line 197 in bd942bc
if (spec.primaryKey && options.emitPrimaryKey) { |
It would seem options are not passed here:
node-db-migrate/lib/driver/base.js
Line 178 in bd942bc
var def = this.createColumnDef(columnName, this.normalizeColumnSpec(columnSpec)); |
Therefore resulting on the undefined.
Keep up the good work, and cheers!