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

const Group = sequelize.define('Group', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        allowNull: false,
    },
    diaryDateId: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: DiaryDate,
            key: 'id',
        },
        onDelete: 'CASCADE',
    },
    name: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    lead: {
        type: DataTypes.STRING,
        allowNull: true,
    }
}, {
    tableName: 'group',
    underscored: true,
    timestamps: true,
});

export default Group;
