-- Job Arranger upgrade table SQL for PostgreSQL (Ver 7.2.2)  - 2026/03/03 -

-- Copyright (C) 2012-2014 FitechForce, Inc. All Rights Reserved.
-- Copyright (C) 2024 Daiwa Institute of Research Business Innovation Ltd. All Rights Reserved.

ALTER TABLE ja_2_run_jobnet_table
ADD COLUMN IF NOT EXISTS test_run_time BIGINT NOT NULL DEFAULT 0
CHECK (test_run_time >= 0);

ALTER TABLE ja_2_ran_jobnet_table
ADD COLUMN IF NOT EXISTS test_run_time BIGINT NOT NULL DEFAULT 0
CHECK (test_run_time >= 0);

CREATE INDEX ja_job_idx_join_filter ON ja_2_run_job_table (inner_job_id,inner_jobnet_id,status);
CREATE INDEX ja_jend_exists_idx ON ja_2_run_job_table (inner_job_id,inner_jobnet_id,status) WHERE end_time <> 0;
CREATE INDEX ja_job_status0_idx ON ja_2_run_job_table (inner_job_id,inner_jobnet_id) WHERE status = 0;
CREATE INDEX ja_job_start_status3_idx ON ja_2_run_job_table (inner_jobnet_id,inner_job_id,end_time) WHERE status = 3;

CREATE INDEX ja_2_run_flow_idx_jobnet_start_end ON ja_2_run_flow_table (inner_jobnet_id,start_inner_job_id,end_inner_job_id);
CREATE INDEX ja_2_run_flow_idx_end ON ja_2_run_flow_table (end_inner_job_id,start_inner_job_id);



