node.js - Sequelize Migration Error -
i'm using sequelize 2.0.0-rc3 , there's error i'm encountering; seems i'm writing migration correctly i'm getting error trying run it. i'm using postgresql on backend. seems working fine; new, isolated issue. document table , id column exists (created in previous migration, discovered it's not auto-incrementing id's; tried creating migration add auto-incrementing).
var p = require('bluebird'); module.exports = { up: function (migration, datatypes, done) { var promises = []; promises.push( migration.changecolumn( 'document', 'id', { type: datatypes.integer, primarykey: true, autoincrement: true, allownull: false } )); p.all(promises).then(done.bind(null, null)).catch(function (err) { console.error('migration failed: ', err); done(err); }); }, down: function (migration, datatypes, done) { done(); } };
possibly unhandled typeerror: cannot call method 'push' of undefined @ object.module.exports.querygenerator.datatypemapping (/users/csimpson/code/temp-cause-server/node_modules/sequelize/lib/dialects/postgres/query-generator.js:848:32) @ object.module.exports.querygenerator.pgdatatypemapping (/users/csimpson/code/temp-cause-server/node_modules/sequelize/lib/dialects/postgres/query-generator.js:843:19) @ object.module.exports.querygenerator.changecolumnquery (/users/csimpson/code/temp-cause-server/node_modules/sequelize/lib/dialects/postgres/query-generator.js:250:31) @ module.exports.queryinterface.changecolumn (/users/csimpson/code/temp-cause-server/node_modules/sequelize/lib/query-interface.js:345:37) @ module.exports.migration.(anonymous function) [as changecolumn] (/users/csimpson/code/temp-cause-server/node_modules/sequelize/lib/migration.js:26:50) @ /users/csimpson/code/temp-cause-server/database/migrations/20141216000001-alter-id-increment.js:8:41 @ trycatch1 (/users/csimpson/code/temp-cause-server/node_modules/sequelize/node_modules/bluebird/js/main/util.js:45:21) @ promise$_callhandler [as _callhandler] (/users/csimpson/code/temp-cause-server/node_modules/sequelize/node_modules/bluebird/js/main/promise.js:660:13) @ promise$_settlepromisefromhandler [as _settlepromisefromhandler] (/users/csimpson/code/temp-cause-server/node_modules/sequelize/node_modules/bluebird/js/main/promise.js:675:18) @ promise$_settlepromiseat (/users/csimpson/code/temp-cause-server/node_modules/sequelize/node_modules/bluebird/js/main/promise.js:845:14)
i ran possibly unhandled typeerror: cannot call method 'push' of undefined
error well. trying add id
field existing table, 1 had created in previous migration.
my fix had 2 parts:
1) add unique: true
id
column.
2) undo previous migration (where created table want add id
column to), , run both migrations @ once.
until did both of these, migration attempts failed.
Comments
Post a Comment