-- Migration: Create ai_task_generation_history table
-- Date: 2025-01-XX
-- Description: Creates table to store AI task generation history (request and response) for projects

CREATE TABLE IF NOT EXISTS ai_task_generation_history (
    id VARCHAR(36) PRIMARY KEY,
    project_id VARCHAR(36) NOT NULL,
    request_prompt TEXT NOT NULL COMMENT '送信したプロンプト内容',
    response_json TEXT NOT NULL COMMENT 'AIからのレスポンス（JSON形式をそのまま保存）',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
    INDEX idx_project_id (project_id),
    INDEX idx_created_at (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

