-- 설비 사진 테이블 생성
-- 실행: docker exec -i tkfb_db mysql -u hyungi -p'your_password' hyungi < db/migrations/20260205001000_create_equipment_photos.sql

CREATE TABLE IF NOT EXISTS equipment_photos (
  photo_id INT AUTO_INCREMENT PRIMARY KEY,
  equipment_id INT UNSIGNED NOT NULL,
  photo_path VARCHAR(255) NOT NULL COMMENT '이미지 경로',
  description VARCHAR(200) COMMENT '사진 설명',
  display_order INT DEFAULT 0 COMMENT '표시 순서',
  uploaded_by INT COMMENT '업로드한 사용자 ID',
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  CONSTRAINT fk_eq_photos_equipment FOREIGN KEY (equipment_id)
    REFERENCES equipments(equipment_id) ON DELETE CASCADE,
  CONSTRAINT fk_eq_photos_user FOREIGN KEY (uploaded_by)
    REFERENCES users(user_id) ON DELETE SET NULL,
  INDEX idx_eq_photos_equipment_id (equipment_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
