module.exports = function (sequelize, DataTypes) {
    const EntityType = sequelize.define('EntityType', {
        id: {
            type: DataTypes.UUID,
            defaultValue: DataTypes.UUIDV4,
            primaryKey: true,
        },
        name: {
            type: DataTypes.STRING,
            allowNull: false
        },
        alias: {
            type: DataTypes.STRING(45),
            allowNull: false
        },
    }, {
        tableName: 'entities_types',
        freezeTableName: true,
        timestamps: true,
    });

    EntityType.associate = function (models) {
        EntityType.Entities = EntityType.belongsToMany(models.Entity, {
            through: models.EntityEntitiesTypes,
            foreignKey: 'typeId'
        });
    };

    return EntityType;
};