'use strict';
module.exports = (sequelize, DataTypes) => {
  const Event = sequelize.define('Event', {
    name: {
      type: DataTypes.STRING,
      allowNull: false
    },
    posterPath: {
      type: DataTypes.STRING,
      allowNull: false
    },
    reportPath: {
      type: DataTypes.STRING,
      allowNull: true
    },
    yearId: {
      type: DataTypes.INTEGER,
      allowNull: false
    }
  });

  Event.associate = (models) => {
    Event.belongsTo(models.EventYear, {
      foreignKey: 'yearId',
      onDelete: 'CASCADE'
    });
  };

  return Event;
};
