'use strict';

module.exports = function (sequelize, DataTypes) {
    const EventType = sequelize.define('EventType', {
        id: {
            type: DataTypes.UUID,
            defaultValue: DataTypes.UUIDV4,
            primaryKey: true,
        },
        name: {
            type: DataTypes.STRING,
        },
        title: {
            type: DataTypes.STRING,
        },
    }, {
        tableName: 'event_types',
        freezeTableName: true,
        timestamps: true,
    });

    EventType.associate = function (models) {
        EventType.Events = EventType.hasMany(models.Event, { foreignKey: 'typeId' });
    };

    return EventType;
};