import { DataTypes } from 'sequelize';
import sequelize from '../database.js';
import DiaryDateActivity from './DiaryDateActivity.js';
import Group from './Group.js';

const GroupActivity = sequelize.define('GroupActivity', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
    },
    diaryDateActivity: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: DiaryDateActivity,
            key: 'id'
        },
        onDelete: 'CASCADE'
    },
    groupId: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: Group,
            key: 'id',
        },
        onDelete: 'CASCADE'
    },
    customActivity: {
        type: DataTypes.INTEGER,
        allowNull: true,
    },
    duration: {
        type: DataTypes.INTEGER,
        allowNull: true
    },
    durationText: {
        type: DataTypes.STRING,
        allowNull: true
    },
    orderId: {
        type: DataTypes.INTEGER,
        allowNull: false,
        defaultValue: 1
    },
}, {
    tableName: 'group_activity',
    underscored: true,
    timestamps: true,
});

export default GroupActivity;