I'm working with sequelize associations. I've seen many ways to add foreign keys, is the way I'm doing it correctly?
What I'm trying to do is add a foreign key constraint to my profile_personals table from my parent table (users, "user_id")
const Sequelize = require('sequelize')
const db = require('../database/db.js')
const Users = require('../model/User.js')
module.exports = db.sequelize.define(
'profile_personals',
{
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
biography: {
type: Sequelize.STRING
},
fk_user_id: {
type: Sequelize.INTEGER,
references: {
// This is a reference to another model
model: Users,
// This is the column name of the referenced model
key: 'user_id'
}
}
},
{
timestamps: false
}
)