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

const ClubCommunicationMessage = sequelize.define('ClubCommunicationMessage', {
  id: {
    type: DataTypes.BIGINT,
    primaryKey: true,
    autoIncrement: true,
    allowNull: false,
  },
  threadId: {
    type: DataTypes.BIGINT,
    allowNull: false,
    field: 'thread_id',
  },
  clubId: {
    type: DataTypes.BIGINT,
    allowNull: false,
    field: 'club_id',
  },
  messageType: {
    type: DataTypes.ENUM('message', 'note'),
    allowNull: false,
    defaultValue: 'message',
    field: 'message_type',
  },
  direction: {
    type: DataTypes.ENUM('outbound', 'internal', 'inbound'),
    allowNull: false,
    defaultValue: 'outbound',
  },
  body: {
    type: DataTypes.TEXT,
    allowNull: false,
  },
  createdByUserId: {
    type: DataTypes.BIGINT,
    allowNull: true,
    field: 'created_by_user_id',
  },
}, {
  underscored: true,
  tableName: 'club_communication_messages',
  timestamps: true,
});

export default ClubCommunicationMessage;
