Cannot addColumn with a primaryKey on Postgres
See original GitHub issueHello!
After browsing the issues, I found a similar issue posted a couple of days ago (https://github.com/db-migrate/node-db-migrate/issues/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: https://github.com/db-migrate/node-db-migrate/blob/bd942bca54fb1d85592e840999529449ac12f055/lib/driver/pg.js#L197
It would seem options are not passed here: https://github.com/db-migrate/node-db-migrate/blob/bd942bca54fb1d85592e840999529449ac12f055/lib/driver/base.js#L178
Therefore resulting on the undefined.
Keep up the good work, and cheers!
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
I will c if I will backport this to the v0.9.x track. As long as 0.10.x is not released on the main track 0.9.x is still supported though.
Was backported and released under the latest 0.9.x track.