
-- DROP TABLE fw_core.fw_jobctl_runschedule;

CREATE TABLE fw_core.fw_jobctl_runschedule (
	syspk bigserial NOT NULL,
	client_id fw_core.fw_num_dimid NOT NULL,
	function_id fw_core.fw_num_dimid NOT NULL,
	latest_runschedule_flag fw_core.fw_flag_bool NOT NULL DEFAULT true,
	run_schedule_id bigserial NOT NULL,
	run_frequency fw_core.fw_alphnum NOT NULL,
	run_schedule_timestamp fw_core.fw_timestamp NOT NULL,
	begin_status fw_core.fw_alphnum NULL,
	end_status fw_core.fw_alphnum NULL DEFAULT NULL::text,
	end_status_note fw_core.fw_alphnum NULL DEFAULT NULL::text,
	object_count fw_core.fw_num_dimid NULL,
	start_time fw_core.fw_timestamp NULL,
	end_time fw_core.fw_timestamp NULL,
	created_by fw_core.fw_alphnum NOT NULL,
	updated_by fw_core.fw_alphnum NOT NULL,
	create_timestamp fw_core.fw_timestamp NOT NULL DEFAULT now(),
	update_timestamp fw_core.fw_timestamp NOT NULL DEFAULT now(),
	CONSTRAINT fw_jobctl_runschedule_pkey1 PRIMARY KEY (syspk),
	CONSTRAINT unique_jobctl_runschedule1 UNIQUE (client_id, function_id, run_schedule_id, run_frequency)
);


-- DROP TABLE fw_core.fw_jobctl_runschedule_jobstep;

CREATE TABLE fw_core.fw_jobctl_runschedule_jobstep (
	syspk bigserial NOT NULL,
	client_id fw_core.fw_num_dimid NOT NULL,
	function_id fw_core.fw_num_dimid NOT NULL,
	latest_runschedule_flag fw_core.fw_flag_bool NOT NULL DEFAULT true,
	run_schedule_id fw_core.fw_num_dimid NULL,
	run_frequency fw_core.fw_alphnum NOT NULL,
	run_schedule_timestamp fw_core.fw_timestamp NOT NULL,
	job_id fw_core.fw_num_dimid NOT NULL,
	step_id fw_core.fw_num_dimid NOT NULL,
	job_step_run_dependency_seuqence fw_core.fw_num_dimid NOT NULL,
	job_script_type fw_core.fw_alphnum NOT NULL,
	job_step_script_name fw_core.fw_alphnum NOT NULL,
	job_fun_param_array fw_core.fw_text_array NULL,
	job_scope fw_core.fw_alphnum NULL,
	job_scope_qualifier_array fw_core.fw_text_array NULL,
	job_name fw_core.fw_alphnum NULL,
	step_name fw_core.fw_alphnum NULL,
	begin_status fw_core.fw_alphnum NULL DEFAULT NULL::text,
	end_status fw_core.fw_alphnum NULL DEFAULT NULL::text,
	end_status_note fw_core.fw_alphnum NULL DEFAULT NULL::text,
	start_time fw_core.fw_timestamp NULL,
	end_time fw_core.fw_timestamp NULL,
	created_by fw_core.fw_alphnum NULL,
	updated_by fw_core.fw_alphnum NULL,
	create_timestamp fw_core.fw_timestamp NOT NULL DEFAULT now(),
	update_timestamp fw_core.fw_timestamp NOT NULL DEFAULT now(),
	CONSTRAINT fw_jobctl_runschedule_jobstep_pkey1 PRIMARY KEY (syspk),
	CONSTRAINT unique_jobctl_runschedule_jobstep1 UNIQUE (client_id, function_id, run_schedule_id, run_frequency, job_id, step_id)
);



-- DROP TABLE fw_core.fw_jobctl_jobstep_master;

CREATE TABLE fw_core.fw_jobctl_jobstep_master (
	syspk bigserial NOT NULL,
	client_id fw_core.fw_num_dimid NOT NULL,
	function_id fw_core.fw_num_dimid NOT NULL,
	run_frequency fw_core.fw_alphanum NOT NULL,
	job_scheduling_day fw_core.fw_alphanum NOT NULL,
	sch_day_of_month fw_core.fw_alphanum NOT NULL,
	sch_day_of_week fw_core.fw_alphanum NOT NULL,
	sch_hour_of_day fw_core.fw_time NOT NULL,
	sch_minute_of_hour fw_core.fw_time NOT NULL,
	job_id fw_core.fw_num_dimid NOT NULL,
	step_id fw_core.fw_num_dimid NOT NULL,
	job_step_run_dependency_seuqence fw_core.fw_num_dimid NOT NULL,
	active_flag fw_core.fw_flag_bool NOT NULL DEFAULT true,
	job_name fw_core.fw_alphanum NULL,
	step_name fw_core.fw_alphanum NULL,
	job_script_type fw_core.fw_alphanum NOT NULL,
	job_step_script_name fw_core.fw_alphanum NOT NULL,
	job_fun_param_array fw_core.fw_text_array NULL,
	job_scope fw_core.fw_alphanum NULL,
	job_scope_qualifier_array fw_core.fw_text_array NULL,
	sme_entering fw_core.fw_alphanum NULL,
	extract_field_name fw_core.fw_alphanum NULL,
	job_step_description fw_core.fw_alphanum NULL,
	job_step_objective fw_core.fw_alphanum NULL,
	created_by fw_core.fw_alphanum NOT NULL,
	updated_by fw_core.fw_alphanum NOT NULL,
	create_timestamp fw_core.fw_timestamp NOT NULL DEFAULT now(),
	update_timestamp fw_core.fw_timestamp NOT NULL DEFAULT now(),
	CONSTRAINT fw_jobctl_jobstep_master_pkey1 PRIMARY KEY (syspk),
	CONSTRAINT unique_jobctl_jobstep_master1 UNIQUE (client_id,function_id,run_frequency,job_id,step_id)
);


