'use strict'; module.exports = (sequelize, DataTypes) => { const ChatMessage = sequelize.define('ChatMessage', { id: { type: DataTypes.BIGINT, autoIncrement: true, primaryKey: true }, user_id: { type: DataTypes.BIGINT, allowNull: false }, isotope_id: { type: DataTypes.BIGINT, allowNull: false }, role: { type: DataTypes.ENUM('user', 'assistant'), allowNull: false }, message: { type: DataTypes.TEXT, allowNull: false } }, { tableName: 'chat_messages', underscored: true, timestamps: true }); ChatMessage.associate = function(models) { ChatMessage.belongsTo(models.User, { foreignKey: 'user_id', onDelete: 'CASCADE' }); ChatMessage.belongsTo(models.Isotope, { foreignKey: 'isotope_id', onDelete: 'CASCADE' }); }; return ChatMessage; };