--ABS-153450 
CREATE SEQUENCE SEQ_A_TABLELIST
MINVALUE 1
MAXVALUE 9999999999999999999999999999
START WITH 1
INCREMENT BY 1;

ALTER TABLE A_TABLELIST ADD (A_TABLELIST_ID NUMBER NULL);

UPDATE A_TABLELIST A
SET A.A_TABLELIST_ID = SEQ_A_TABLELIST.NEXTVAL;
COMMIT;

ALTER TABLE A_TABLELIST MODIFY (A_TABLELIST_ID NOT NULL);
ALTER TABLE A_TABLELIST ADD CONSTRAINT PK2_A_TABLELIST UNIQUE (A_TABLELIST_ID);


COMMENT ON COLUMN A_TABLELIST.DAYS_TO_KEEP
  IS '0 Means do NOT cleanup data same as leaving it blank';
ALTER TABLE A_TABLELIST
  DROP CONSTRAINT CHK_INDX_A_TABLELIST_DAYS_TO_KEEP;
ALTER TABLE A_TABLELIST
  ADD CONSTRAINT CHK_INDX_A_TABLELIST_DAYS_TO_KEEP
  CHECK (DAYS_TO_KEEP BETWEEN 0 AND 9999);

DROP TYPE T_AUDIT_TAB;
DROP TYPE T_AUDIT;

CREATE TYPE T_AUDIT AS OBJECT (
  TABLE_NAME VARCHAR2(100),
  UNIQUE_KEY VARCHAR2(1000),
  TIMESTAMP DATE,
  ACTION VARCHAR2(1000),
  COLUMN_NAME VARCHAR2(100),
  OLD_VALUE VARCHAR2(1000),
  NEW_VALUE VARCHAR2(1000),
  BUSINESSUNIT_CODE VARCHAR2(6),
  BUSINESSUNIT_DESC VARCHAR2(40),
  SYSUSER VARCHAR2(1000),
  WORKSTATION VARCHAR2(40),
  EXTRAFIELD1 VARCHAR2(1000),
  EXTRAFIELD2 VARCHAR2(1000),
  EXTRAFIELD3 VARCHAR2(1000),
  EXTRAFIELD4 VARCHAR2(1000),
  EXTRAFIELD5 VARCHAR2(1000),
  EXTRAFIELD6 VARCHAR2(1000),
  ROWNUMBER VARCHAR2(1000));

CREATE TYPE T_AUDIT_TAB IS TABLE OF T_AUDIT;
