// models/DiaryNote.js
import { DataTypes } from 'sequelize';
import sequelize from '../database.js';
import Member from './Member.js';

const DiaryNote = sequelize.define('DiaryNote', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        allowNull: false,
    },
    content: {
        type: DataTypes.TEXT,
        allowNull: false,
    },
    memberId: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: Member,
            key: 'id',
        },
        onDelete: 'CASCADE',
        onUpdate: 'CASCADE',
    },
    diaryDateId: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: 'diary_dates', 
            key: 'id',
        },
        onDelete: 'CASCADE',
        onUpdate: 'CASCADE',
    },
}, {
    underscored: true,
    tableName: 'diary_notes',
    timestamps: true,
});

export default DiaryNote;
