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

const ClubDocumentLink = sequelize.define('ClubDocumentLink', {
  documentId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    field: 'document_id',
  },
  linkedEntityType: {
    type: DataTypes.STRING(32),
    allowNull: false,
    field: 'linked_entity_type',
  },
  linkedEntityId: {
    type: DataTypes.BIGINT,
    allowNull: false,
    field: 'linked_entity_id',
  },
  createdAt: {
    type: DataTypes.DATE,
    allowNull: false,
    defaultValue: DataTypes.NOW,
    field: 'created_at',
  },
}, {
  tableName: 'club_document_links',
  underscored: true,
  timestamps: false,
  indexes: [
    { fields: ['linked_entity_type', 'linked_entity_id'] },
  ],
});

export default ClubDocumentLink;
