ALTER TABLE tctg_chi_category_hierarchy
MODIFY (chi_parent_id not null, chi_child_id not null, chi_next_version_id not null, chi_company_id not null)
ADD CONSTRAINT CHI_0_PK PRIMARY KEY (chi_parent_id, chi_child_id, chi_next_version_id, chi_company_id);
---

DROP INDEX ictg_cat_0;
DROP INDEX ictg_cat_1;
DROP INDEX ictg_cat_2;
DROP INDEX ictg_cat_3;
ALTER TABLE tctg_cat_category
MODIFY (cat_id not null, cat_company_id not null)
ADD CONSTRAINT CAT_0_PK PRIMARY KEY (cat_id, cat_next_version_id, cat_container_id, cat_company_id);
CREATE INDEX ictg_cat_0
  ON tctg_cat_category (
    cat_container_id,
    cat_next_version_id,
    cat_version_id,
    cat_primary_key,
    cat_id
  )
  TABLESPACE indx
;
CREATE INDEX ictg_cat_1
  ON tctg_cat_category (
    cat_primary_key,
    cat_next_version_id,
    cat_version_id,
    cat_container_id,
    cat_id
  )
  TABLESPACE indx
;
CREATE INDEX ictg_cat_2
  ON tctg_cat_category (
    cat_container_id,
    cat_last_modified,
    cat_id
  )
  TABLESPACE indx
;
---

DROP INDEX ictg_itm_0;
DROP INDEX ictg_itm_1;
DROP INDEX ictg_itm_2;
DROP INDEX ictg_itm_3;
ALTER TABLE tctg_itm_item
MODIFY (itm_id not null, itm_company_id not null)
ADD CONSTRAINT ITM_0_PK PRIMARY KEY (itm_id, itm_next_version_id, itm_container_id, itm_company_id);
CREATE INDEX ictg_itm_0
  ON tctg_itm_item (
    itm_primary_key,
    itm_container_id,
    itm_next_version_id,
    itm_version_id,
    itm_id,
    itm_company_id
  )
  TABLESPACE indx
;
CREATE INDEX ictg_itm_1
  ON tctg_itm_item (
    itm_container_id,
    itm_next_version_id,
    itm_version_id,
    itm_id,
    itm_company_id
  )
  TABLESPACE indx
;
CREATE INDEX ictg_itm_2
  ON tctg_itm_item (
    UPPER("ITM_PRIMARY_KEY"),
    ITM_CONTAINER_ID,
    ITM_VERSION_ID,
    ITM_NEXT_VERSION_ID,
    ITM_ID
  )
  TABLESPACE indx
;
---

DROP INDEX ictg_icm_3; 
ALTER TABLE tctg_icm_item_category_map
MODIFY (icm_item_id not null, icm_next_version_id not null, icm_cat_tree_id not null, icm_category_id not null, icm_company_id not null)
ADD CONSTRAINT ICM_0_PK PRIMARY KEY (icm_item_id, icm_next_version_id, icm_cat_tree_id, icm_category_id, icm_company_id );
---

DROP INDEX ictg_cfp_1;
DROP INDEX ictg_cfp_2;
ALTER TABLE tctg_cfp_cat_full_paths DROP CONSTRAINT cfp_0_uk CASCADE;
ALTER TABLE tctg_cfp_cat_full_paths
ADD CONSTRAINT CFP_0_PK PRIMARY KEY (cfp_full_path, cfp_full_path_type, cfp_next_version_id, cfp_cat_tree_id);
CREATE INDEX ictg_cfp_1
  ON tctg_cfp_cat_full_paths (
    cfp_cat_tree_id,
    cfp_full_path_type,
    cfp_next_version_id,
    cfp_version_id
  )
  TABLESPACE indx
;
---

DROP INDEX ictg_noh_0;
DROP INDEX ictg_noh_1;
DROP INDEX ictg_noh_2;
DROP INDEX ictg_noh_3;
ALTER TABLE tctg_noh_node_hierarchy
MODIFY (noh_spec_id not null, noh_next_version_id not null, noh_order not null, noh_company_id not null)
ADD CONSTRAINT NOH_0_PK PRIMARY KEY (noh_spec_id, noh_next_version_id, noh_order, noh_company_id);
CREATE INDEX ictg_noh_0
  ON tctg_noh_node_hierarchy (
    noh_child_node_id,
    noh_next_version_id,
    noh_version_id,
    noh_spec_id,
    noh_company_id
  )
  TABLESPACE indx
;
CREATE INDEX ictg_noh_1
  ON tctg_noh_node_hierarchy (
    noh_parent_node_id,
    noh_next_version_id,
    noh_version_id,
    noh_spec_id,
    noh_company_id
  )
  TABLESPACE indx
;
CREATE INDEX ictg_noh_2
  ON tctg_noh_node_hierarchy (
    noh_child_node_id,
    noh_parent_node_id,
    noh_next_version_id,
    noh_version_id,
    noh_spec_id,
    noh_company_id
  )
  TABLESPACE indx
;
---

DROP INDEX ictg_nod_3;
ALTER TABLE tctg_nod_node
MODIFY (nod_id not null, nod_next_version_id not null, nod_spec_id not null, nod_company_id not null)
ADD CONSTRAINT NOD_0_PK PRIMARY KEY (nod_id, nod_next_version_id, nod_spec_id, nod_company_id);
---

DROP INDEX iwfl_wfe_0;
DROP INDEX iwfl_wfe_1;
ALTER TABLE twfl_wfe_workflow_event
MODIFY (wfe_id not null)
ADD CONSTRAINT WFE_0_PK PRIMARY KEY (wfe_id);
CREATE INDEX iwfl_wfe_0
  ON twfl_wfe_workflow_event (
    wfe_event_status,
    wfe_id
  )
  TABLESPACE indx
;
---

ALTER TABLE twfl_wee_workflow_event_entry ADD CONSTRAINT wee_fk_0 FOREIGN KEY (wee_event_id) references twfl_wfe_workflow_event (wfe_id);
