--THIS FILE IS NEEDED ONLY FOR THE ONLINE UPDATE OR WHEN UPGRADING FROM VERSION 8.8.2.4!!!

--UPDATE FROM 8.8.2.4 TO 8.8.3.0


DROP TABLE VERSION_8_8_2_4;



/*  VERSION_8_8_3_0  */
CREATE TABLE VERSION_8_8_3_0 (
	 DUMMY	NUMBER	    NULL
)
;


ALTER TABLE ROTM ADD ROTM_DISPLAYSTARTTIME DATE;

ALTER TABLE RRES ADD RRES_SHARABLE NUMBER (1);

COMMENT ON COLUMN RRES.RRES_SHARABLE IS 'Allow this reservation to be shared';

CREATE TABLE YTRX
(
   YTRX_ID           NUMBER (30)
  ,YTRX_CALCDATE     DATE 
  ,YTRX_CALCFORDATE  DATE
  ,YTRX_RESTYPE      NUMBER (1)
  ,YTRX_YCAT_ID      NUMBER (30)
  ,YTRX_XCMA_ID      NUMBER (30)
  ,YTRX_GROSS_TOTAL  NUMBER (30,4)
  ,YTRX_NET_TOTAL    NUMBER (30,4)
  ,YTRX_GROSS_ROOM   NUMBER (30,4)
  ,YTRX_NET_ROOM     NUMBER (30,4) 
  ,YTRX_NOOFROOMS    NUMBER(3)          
  ,YTRX_DEFROOMS     NUMBER(3)          
  ,YTRX_ADULTNO      NUMBER(10)         
  ,YTRX_DEFADULTNO   NUMBER(10)         
  ,YTRX_CHILDNO      NUMBER(10)         
  ,YTRX_DEFCHILDNO   NUMBER(10)         
  ,YTRX_CHILDNODOMESTIC    NUMBER(10)         
  ,YTRX_DEFCHILDNODOMESTIC NUMBER(10)         
  ,CONSTRAINT YTRX_PK PRIMARY KEY (YTRX_ID) USING INDEX TABLESPACE V8INDEX
) TABLESPACE V8MAIN;

CREATE SEQUENCE SEQ_YTRX INCREMENT BY 1 START WITH 1000 NOMAXVALUE NOCYCLE NOCACHE NOORDER;

COMMENT ON TABLE YTRX IS 'Trend analyisis Market Code per Roomtype per reservationtype Forecast';

COMMENT ON COLUMN YTRX.YTRX_RESTYPE IS '1=Individual reservation, 2= Group, 3=Block ';

CREATE TABLE RRYB (
    RRYB_ID NUMBER(30) NOT NULL,
    RRYB_RRES_ID NUMBER(30) NOT NULL,
    RRYB_YBOM_ID NUMBER(30),
    RRYB_YEVM_ID NUMBER(30),
    RRYB_YEBS_ID NUMBER(30),
    CONSTRAINT RRYB_PK PRIMARY KEY (RRYB_ID) USING INDEX TABLESPACE V8INDEX) TABLESPACE V8MAIN;

CREATE SEQUENCE SEQ_RRYB INCREMENT BY 1 START WITH 1000 NOMAXVALUE NOCYCLE NOCACHE NOORDER;

COMMENT ON TABLE RRYB IS 'Table reservations linked to CCM';

COMMENT ON COLUMN RRYB.RRYB_RRES_ID IS 'Table Reservation ID';

COMMENT ON COLUMN RRYB.RRYB_YBOM_ID IS 'Booking ID';

COMMENT ON COLUMN RRYB.RRYB_YEVM_ID IS 'Event ID';

COMMENT ON COLUMN RRYB.RRYB_YEBS_ID IS 'Function Space Booked ID';

UPDATE RRES SET RRES_YEBS_ID=NULL;

ALTER TABLE RRES DROP COLUMN RRES_YEBS_ID;

ALTER TABLE RRST ADD RRST_YFSC_ID NUMBER(30);

CREATE TABLE YFAL (
    YFAL_ID NUMBER(30) NOT NULL
   ,YFAL_YRES_ID NUMBER(30) NOT NULL
   ,YFAL_ZFAC_ID NUMBER(30) NOT NULL
   ,YFAL_ROLE NUMBER(1) NOT NULL
   ,CONSTRAINT YFAL_PK PRIMARY KEY (YFAL_ID) USING INDEX TABLESPACE V8INDEX) TABLESPACE V8MAIN;

CREATE SEQUENCE SEQ_YFAL INCREMENT BY 1 START WITH 1000 NOMAXVALUE NOCYCLE NOCACHE NOORDER;

COMMENT ON TABLE YFAL IS 'reservation - financial account link';

COMMENT ON COLUMN YFAL.YFAL_ROLE IS '0=prearrival 1=postdeparture';

ALTER TABLE WSCT ADD WSCT_DESCRIPTION VARCHAR(30);

ALTER TABLE YPRR ADD YPRR_EB_CALCMETHOD NUMBER(1);

COMMENT ON COLUMN YPRR.YPRR_EB_CALCMETHOD IS '1: Percentage, 2:Night  3: Stay ';

ALTER TABLE YPRR ADD YPRR_EB_POSTDAY NUMBER(1);

COMMENT ON COLUMN YPRR.YPRR_EB_POSTDAY IS '0: option disabled(percentage calculation), 1: Average, 2:First Day  3: Last Day ';

UPDATE YPRR SET YPRR_EB_CALCMETHOD=1, YPRR_EB_POSTDAY=0 WHERE NVL(YPRR_FIXAMOUNTPERNIGHT,0)=0;

UPDATE YPRR SET YPRR_EB_CALCMETHOD=2 ,YPRR_EB_POSTDAY=2 WHERE NVL(YPRR_FIXAMOUNTPERNIGHT,0)>0;

COMMENT ON COLUMN YPRR.YPRR_FIXAMOUNTPERNIGHT IS 'Obsolete column, not supported anymore';

ALTER TABLE WMAI ADD WMAI_DRAFT NUMBER(1);

COMMENT ON COLUMN WMAI.WMAI_DRAFT IS 'The email saved for future editing';

ALTER TABLE WMAI MODIFY WMAI_TO NULL;

ALTER TABLE WMAI MODIFY WMAI_SUBJECT NULL;
