"use strict"; const { Model } = require("sequelize"); module.exports = (sequelize, DataTypes) => { class ActivityLog extends Model { /** * Helper method for defining associations. * This method is not a part of Sequelize lifecycle. * The `models/index` file will call this method automatically. */ static associate(models) { this.belongsTo(models.User, { foreignKey: "userId" }); } } ActivityLog.init( { userId: { type: DataTypes.INTEGER, allowNull: false, references: { model: "Users", key: "id", }, }, action: { type: DataTypes.STRING, allowNull: false, }, details: { type: DataTypes.TEXT, allowNull: true, }, timestamp: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW, }, }, { sequelize, modelName: "ActivityLog", } ); return ActivityLog; };