-- Migration: Store group photos for later member photo cropping.

CREATE TABLE IF NOT EXISTS `member_group_photo` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `club_id` INT NOT NULL,
  `title` VARCHAR(255) NOT NULL,
  `description` TEXT NULL,
  `file_name` VARCHAR(255) NOT NULL,
  `original_file_name` VARCHAR(255) NULL,
  `mime_type` VARCHAR(100) NULL,
  `file_size` INT NULL,
  `width` INT NULL,
  `height` INT NULL,
  `taken_at` DATETIME NULL,
  `created_by_user_id` INT NULL,
  `created_at` DATETIME NOT NULL,
  `updated_at` DATETIME NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `idx_member_group_photo_club_id` (`club_id`),
  CONSTRAINT `fk_member_group_photo_club`
    FOREIGN KEY (`club_id`) REFERENCES `clubs` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_member_group_photo_created_by`
    FOREIGN KEY (`created_by_user_id`) REFERENCES `user` (`id`)
    ON DELETE SET NULL
    ON UPDATE CASCADE
);
