CREATE TABLE IF NOT EXISTS rekognition_atmosphere_images (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  event_id BIGINT UNSIGNED NOT NULL,
  original_name VARCHAR(255) NOT NULL,
  s3_bucket VARCHAR(255) NOT NULL,
  s3_key VARCHAR(1024) NOT NULL,
  thumbnail_s3_key VARCHAR(1024) NULL,
  thumbnail_status ENUM('pending', 'ready', 'failed') NOT NULL DEFAULT 'pending',
  thumbnail_error TEXT NULL,
  mime_type VARCHAR(100) NOT NULL,
  file_size BIGINT UNSIGNED NOT NULL,
  uploaded_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  UNIQUE KEY uq_atmosphere_images_s3_key (s3_key(255)),
  KEY idx_atmosphere_images_thumbnail_status (thumbnail_status),
  UNIQUE KEY uq_atmosphere_images_event_original_name (event_id, original_name),
  KEY idx_atmosphere_images_event_id (event_id),
  CONSTRAINT fk_atmosphere_images_event_id
    FOREIGN KEY (event_id) REFERENCES rekognition_events(id)
    ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
