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

module.exports = (sequelize) => {
  const EventType = sequelize.define('EventType', {
    caption: {
      type: DataTypes.STRING,
      allowNull: false
    }
  }, {
    tableName: 'event_types',
    timestamps: false
  });

  EventType.associate = function(models) {
    EventType.hasMany(models.Event, {
      foreignKey: 'eventTypeId',
      as: 'events'
    });
  };

  return EventType;
};
