import { DataTypes } from 'sequelize';
import sequelize from '../database.js';
import Club from './Club.js'; // Importiere das Club-Modell

const DiaryDate = sequelize.define('DiaryDate', {
    date: {
        type: DataTypes.DATEONLY,
        allowNull: false,
    },
    clubId: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: Club,
            key: 'id'
        },
        onDelete: 'CASCADE',
    },
    trainingStart: {
        type: DataTypes.TIME,
        allowNull: true,
    },
    trainingEnd: {
        type: DataTypes.TIME,
        allowNull: true,
    },
    excludeFromBilling: {
        type: DataTypes.BOOLEAN,
        allowNull: false,
        defaultValue: false,
        field: 'exclude_from_billing',
    }
}, {
    tableName: 'diary_dates',
    underscored: true,
    timestamps: true
});

export default DiaryDate;
