---ABS-96487

---PREDEFINEDCONTACTNOTES TABLE
ALTER TABLE PREDEFINEDCONTACTNOTES ADD (AVAILABLEFOR NUMBER DEFAULT 0 NOT NULL); 

COMMENT ON COLUMN PREDEFINEDCONTACTNOTES.AVAILABLEFOR IS 'AvailableFor	Number	N	0 = All plants
                                                          1 = Only for specific plant(s)
                                                          Default 0.';
                                                                                                   
                                                          
---PLANTPREDEFINEDCONTACTNOTES TABLE
CREATE TABLE PLANTPREDEFINEDCONTACTNOTES(
PREDEFINEDCONTACTNOTES_ID      NUMBER NOT NULL, 
PLANT_ID                       NUMBER NOT NULL, 
SYSTEMUSER_ID                  NUMBER NOT NULL,
TIMESTAMP                      DATE   NOT NULL);

ALTER TABLE PLANTPREDEFINEDCONTACTNOTES
  ADD CONSTRAINT XPKPLANTPREDEFINEDCONTACTNOTES PRIMARY KEY (PREDEFINEDCONTACTNOTES_ID, PLANT_ID);

CREATE INDEX XIF1PLANTPREDEFINEDCONTACTNOTES ON PLANTPREDEFINEDCONTACTNOTES (PREDEFINEDCONTACTNOTES_ID);

CREATE INDEX XIF2PLANTPREDEFINEDCONTACTNOTES ON PLANTPREDEFINEDCONTACTNOTES (PLANT_ID);
     
ALTER TABLE PLANTPREDEFINEDCONTACTNOTES 
  ADD CONSTRAINT FK_PLPREDEFCNTNT_PREDEFCNTNT_ID FOREIGN KEY (PREDEFINEDCONTACTNOTES_ID) REFERENCES PREDEFINEDCONTACTNOTES (PREDEFINEDCONTACTNOTES_ID) ON DELETE CASCADE;

ALTER TABLE PLANTPREDEFINEDCONTACTNOTES 
  ADD CONSTRAINT FK_PLPREDEFCNTNT_PLANT_ID FOREIGN KEY (PLANT_ID) REFERENCES PLANT (PLANT_ID) ON DELETE CASCADE;



