ALTER TABLE schedule_tasks
    ALTER COLUMN target_platform TYPE TEXT;

ALTER TABLE schedule_tasks
    ADD COLUMN operator_id BIGINT REFERENCES users(id),
    ADD COLUMN enable_web_search BOOLEAN NOT NULL DEFAULT FALSE,
    ADD COLUMN generate_count INT NOT NULL DEFAULT 1;

ALTER TABLE schedule_tasks
    ADD CONSTRAINT chk_schedule_tasks_generate_count
        CHECK (generate_count >= 1 AND generate_count <= 20);

CREATE INDEX idx_schedule_task_operator
    ON schedule_tasks(tenant_id, operator_id, created_at DESC)
    WHERE deleted_at IS NULL;
