--Order 20013679.120

----WEAREREMPLOYMENT table----

ALTER TABLE WEAREREMPLOYMENT
	ADD (EXTERNALLOCKER_ID NUMBER NULL);

CREATE INDEX XIF8WEAREREMPLOYMENT ON WEAREREMPLOYMENT
(EXTERNALLOCKER_ID   ASC);

ALTER TABLE WEAREREMPLOYMENT
ADD CONSTRAINT WEAREREMPLOYMENT_LOCKER FOREIGN KEY (EXTERNALLOCKER_ID) REFERENCES LOCKER (LOCKER_ID);


----CUSTOMER table----

ALTER TABLE CUSTOMER
	ADD (MAINCUSTOMERTYPE NUMBER  DEFAULT 1 NOT NULL CONSTRAINT MainCustomerType_valid1_1 CHECK (MAINCUSTOMERTYPE IN (1, 2, 3)));

COMMENT ON COLUMN CUSTOMER.MAINCUSTOMERTYPE IS 'Possible values:
1 = not applicable
2 = main customer
3 = belongs to a parent (main) customer
';


----DELIVERYPOINT table---

ALTER TABLE DELIVERYPOINT
	ADD (MAINCUSTOMERDELIVERYPOINT_ID NUMBER NULL);

CREATE UNIQUE INDEX XAK2DELIVERYPOINT ON DELIVERYPOINT
(DELIVERYPOINT_ID   ASC,MAINCUSTOMERDELIVERYPOINT_ID   ASC);

CREATE INDEX XIF7DELIVERYPOINT ON DELIVERYPOINT
(MAINCUSTOMERDELIVERYPOINT_ID   ASC);

ALTER TABLE DELIVERYPOINT
ADD CONSTRAINT DELIVERYPOINT_MAINCUSTDELPOINT FOREIGN KEY (MAINCUSTOMERDELIVERYPOINT_ID) REFERENCES DELIVERYPOINT (DELIVERYPOINT_ID) ON DELETE SET NULL;

