I've been having some problems with Sequelize and foreign keys, they're not created in the database when I sync
this is my Users.js
module.exports = function(sequelize, DataTypes) {
var Users = sequelize.define('users', {
name: DataTypes.STRING
}, {
classMethods: {
associate: function(models) {
Users.belongsTo(models.group);
}
}
});
return Users;
}
and this is my Groups.js
module.exports = function(sequelize, DataTypes) {
var Group = sequelize.define("group", {
nome: DataTypes.STRING
});
return Group;
};
Already tried this:
var Group = require('./Group');
module.exports = function(sequelize, DataTypes) {
var Users = sequelize.define('users', {
name: DataTypes.STRING
});
Users.hasOne(Group);
return Users;
}
but no result.
Obs: I have models.sequelize.sync({ force: true }) on project start
what am I missing?
Thanks!