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

const DiaryMemberTag = sequelize.define('DiaryMemberTag', {
    memberId: {
        type: DataTypes.INTEGER,
        references: {
            model: Member,
            key: 'id',
        },
        onDelete: 'CASCADE',
        allowNull: false,
    },
    diaryDateId: {
        type: DataTypes.INTEGER,
        references: {
            model: DiaryDate,
            key: 'id',
        },
        onDelete: 'CASCADE',
        allowNull: false,
    },
    tagId: {
        type: DataTypes.INTEGER,
        references: {
            model: DiaryTag,
            key: 'id',
        },
        onDelete: 'CASCADE',
        allowNull: false,
    },
}, {
    underscored: true,
    tableName: 'diary_member_tags',
    timestamps: true,
});

export default DiaryMemberTag;
