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

const ClubDistributionGroup = sequelize.define('ClubDistributionGroup', {
  id: {
    type: DataTypes.BIGINT,
    primaryKey: true,
    autoIncrement: true,
    allowNull: false,
  },
  clubId: {
    type: DataTypes.BIGINT,
    allowNull: false,
    field: 'club_id',
  },
  name: {
    type: DataTypes.STRING(255),
    allowNull: false,
  },
  description: {
    type: DataTypes.TEXT,
    allowNull: true,
  },
  groupType: {
    type: DataTypes.ENUM('manual', 'training_group', 'team', 'custom'),
    allowNull: false,
    defaultValue: 'manual',
    field: 'group_type',
  },
  isSystemGroup: {
    type: DataTypes.BOOLEAN,
    allowNull: false,
    defaultValue: false,
    field: 'is_system_group',
  },
  filterDefinition: {
    type: DataTypes.JSON,
    allowNull: true,
    field: 'filter_definition',
  },
}, {
  underscored: true,
  tableName: 'club_distribution_groups',
  timestamps: true,
});

export default ClubDistributionGroup;
