const { DataTypes } = require('sequelize');

module.exports = (sequelize) => {
    const UserActivity = sequelize.define('useractivitie', {
        id: {
            type: DataTypes.INTEGER,
            autoIncrement: true,
            primaryKey: true
        },
        activity_link: { type: DataTypes.STRING(50), allowNull: true },

        // fk
        user_id: {
            type: DataTypes.INTEGER,
            allowNull: false,
            references: {
                model: 'users',
                key: 'id'
            }
        },
    }, {
        tableName: 'useractivities',
        freezeTableName: true
    });

    /**
     * Associates the UserActivity model with other models.
     * @param {object} models - The models to associate with.
     */
    UserActivity.associate = (models) => {
        /**
         * Associates the UserActivity model with the User model.
         * Defines a many-to-one relationship between UserActivity and User.
         * @param {object} models - The models to associate with.
         */
        UserActivity.belongsTo(models.User, { foreignKey: 'user_id', as: 'user' });
    };

    return UserActivity;
};
