I'm using node-orm2 with Postgres and Express to create tables on app start. I've beens sifting through the GitHub issues, but have been unable to find out why non of the other columns are being created. What am I doing wrong?
Console output when starting app with no tables:
[SQL/postgres] SELECT * FROM information_schema.tables WHERE table_name = 'user' [SQL/postgres] CREATE TABLE "user" ("id" SERIAL, PRIMARY KEY ("id")) model_user.js (should create 5 columns, but only creates 1)
var bcrypt = require('bcrypt-nodejs'); module.exports = function(db, cb) { return { id: { type: 'serial', key: true}, // <------- only column that gets created name: { type: 'text', size: 128 }, email: { type: 'text', size: 128 }, createdAt : { type: 'date', required: true, time: true }, password: { type: 'text', size: 128 }, }, { hooks: { beforeValidation: function () { this.createdAt = new Date(); } }, methods : { generateHash: function(password) { return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); }, validPassword: function(password) { return bcrypt.compareSync(password, this.local.password); } } // end methods }; } // end exports config_db.js
var orm = require('orm'); var model_user = require('../models/model_user'); module.exports = function(app) { var opts = { database : "somedb", protocol : "postgres", host : "127.0.0.1", port : 5432, user : "someguy", password : "", query : { pool : true, debug : true, strdates : false } }; app.use(orm.express(opts, { define: function (db, models, next) { models.user = db.define("user", model_user); db.sync(); next(); } })); }