-- Add down migration script here
ALTER TABLE queue RENAME TO v2_job_queue;
CREATE OR REPLACE VIEW queue AS (
    SELECT
        id,
        workspace_id,
        parent_job AS parent_job,
        created_by AS created_by,
        created_at,
        started_at,
        scheduled_for,
        running,
        script_hash AS script_hash,
        script_path AS script_path,
        args AS args,
        logs AS logs,
        raw_code AS raw_code,
        canceled AS canceled,
        canceled_by,
        canceled_reason,
        last_ping AS last_ping,
        job_kind AS job_kind,
        env_id AS env_id,
        schedule_path AS schedule_path,
        permissioned_as AS permissioned_as,
        flow_status AS flow_status,
        raw_flow AS raw_flow,
        is_flow_step AS is_flow_step,
        language AS language,
        suspend,
        suspend_until,
        same_worker AS same_worker,
        raw_lock AS raw_lock,
        pre_run_error AS pre_run_error,
        email AS email,
        visible_to_owner AS visible_to_owner,
        mem_peak AS mem_peak,
        root_job AS root_job,
        leaf_jobs AS leaf_jobs,
        tag,
        concurrent_limit AS concurrent_limit,
        concurrency_time_window_s AS concurrency_time_window_s,
        timeout AS timeout,
        flow_step_id AS flow_step_id,
        cache_ttl AS cache_ttl,
        priority
    FROM v2_job_queue
);
