import { DataTypes } from 'sequelize';
import sequelize from '../database.js';
import Member from './Member.js';
import DiaryDate from './DiaryDates.js';

const Participant = sequelize.define('Participant', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        allowNull: false
    },
    diaryDateId: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: DiaryDate,
            key: 'id'
        }
    },
    memberId: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: Member,
            key: 'id'
        }
    },
    notes: {
        type: DataTypes.STRING(4096),
        allowNull: true,
    }
}, {
    underscored: true,
    tableName: 'participants',
    timestamps: true
});

export default Participant;
