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

const MemberGroupPhoto = sequelize.define('MemberGroupPhoto', {
  id: {
    type: DataTypes.INTEGER,
    autoIncrement: true,
    primaryKey: true,
    allowNull: false
  },
  clubId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    field: 'club_id',
    references: {
      model: 'clubs',
      key: 'id'
    },
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE'
  },
  title: {
    type: DataTypes.STRING(255),
    allowNull: false
  },
  description: {
    type: DataTypes.TEXT,
    allowNull: true
  },
  fileName: {
    type: DataTypes.STRING(255),
    allowNull: false,
    field: 'file_name'
  },
  originalFileName: {
    type: DataTypes.STRING(255),
    allowNull: true,
    field: 'original_file_name'
  },
  mimeType: {
    type: DataTypes.STRING(100),
    allowNull: true,
    field: 'mime_type'
  },
  fileSize: {
    type: DataTypes.INTEGER,
    allowNull: true,
    field: 'file_size'
  },
  width: {
    type: DataTypes.INTEGER,
    allowNull: true
  },
  height: {
    type: DataTypes.INTEGER,
    allowNull: true
  },
  takenAt: {
    type: DataTypes.DATE,
    allowNull: true,
    field: 'taken_at'
  },
  createdByUserId: {
    type: DataTypes.INTEGER,
    allowNull: true,
    field: 'created_by_user_id',
    references: {
      model: 'user',
      key: 'id'
    },
    onDelete: 'SET NULL',
    onUpdate: 'CASCADE'
  }
}, {
  tableName: 'member_group_photo',
  underscored: true,
  timestamps: true
});

export default MemberGroupPhoto;
