-- M7 视频合成与导出

ALTER TABLE ai_tasks
    ADD COLUMN storyboard_id BIGINT NULL AFTER episode_id,
    ADD COLUMN result_tos_key VARCHAR(512) NULL AFTER result_video_url,
    ADD INDEX idx_storyboard (storyboard_id);

CREATE TABLE assembly_tasks (
    id              BIGINT          NOT NULL PRIMARY KEY,
    tenant_id       BIGINT          NOT NULL,
    project_id      BIGINT          NOT NULL,
    episode_id      BIGINT          NOT NULL,
    status          VARCHAR(32)     NOT NULL DEFAULT 'pending',
    shot_count      INT             NOT NULL DEFAULT 0,
    result_tos_key  VARCHAR(512),
    error_message   TEXT,
    created_at      DATETIME(3)     NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    updated_at      DATETIME(3)     NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
    INDEX idx_episode (episode_id),
    INDEX idx_project_tenant (project_id, tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
