__IF_EXISTS__
SELECT 1
  FROM CI_UT_INSTL_DTL
 WHERE SCRIPT_FILE_NAME = 'FW400_BPSCHEMA3.SQL'
   AND END_DTTM IS NOT NULL
/
__THEN__

__EXIT__

__ENDIF__

__IF_EXISTS__
SELECT 1
  FROM USER_TABLES
 WHERE TABLE_NAME = 'F1_INSTALLATION'
/
__ELSE__

__EXIT__

__ENDIF__

__IF_EXISTS__

SELECT 1
  FROM USER_TABLES
 WHERE TABLE_NAME = 'SC_USER'
/
__ELSE__

__EXIT__

__ENDIF__


__IF_EXISTS__
SELECT 1
  FROM USER_TAB_COLUMNS
 WHERE TABLE_NAME = 'SC_USER'
   AND COLUMN_NAME = 'EXT_USER_ID'
/

__ELSE__

ALTER TABLE SC_USER ADD 
(
 EXT_USER_ID VARCHAR2(256 BYTE) NULL
)
/

UPDATE SC_USER SET EXT_USER_ID = RTRIM(USER_ID) WHERE RTRIM(EXT_USER_ID) IS NULL
/


ALTER TABLE SC_USER MODIFY
(
     EXT_USER_ID  NOT NULL
)
/


CREATE  UNIQUE INDEX FC303S1 ON SC_USER
(
	EXT_USER_ID  ASC
)
/


__ENDIF__