-- ABS-24732 / ABS-25196

---BACKORDEREXECUTIONWOL table---
COMMENT ON COLUMN BACKORDEREXECUTIONWOL.DELIVERYPOINT_ID
  IS 'Will only be filled in case items are intended to be shipped to an ordering customer (ShipTo = 2)';

ALTER TABLE BACKORDEREXECUTIONWOL
  DROP CONSTRAINT SHIPTO_CHECK;

ALTER TABLE BACKORDEREXECUTIONWOL
  ADD CONSTRAINT BACKORDEREXECUTIONWOL_CHECK1
  CHECK ((SHIPTO=1 AND SHIPTOSTOCKROOM_ID IS NOT NULL) OR (SHIPTO <> 1 AND SHIPTOSTOCKROOM_ID IS NULL));
  
ALTER TABLE BACKORDEREXECUTIONWOL
  ADD CONSTRAINT BACKORDEREXECUTIONWOL_CHECK2
  CHECK ((SHIPTO=2 AND DELIVERYPOINT_ID IS NOT NULL) OR (SHIPTO <> 2 AND DELIVERYPOINT_ID IS NULL));

---BACKORDEREXECUTIONWOLE table---
COMMENT ON COLUMN BACKORDEREXECUTIONWOLE.DELIVERYPOINT_ID
  IS 'Will only be filled in case items are intended to be shipped to an ordering customer (ShipTo = 2)';

ALTER TABLE BACKORDEREXECUTIONWOLE
  DROP CONSTRAINT SHIPTO_CHECK1;

ALTER TABLE BACKORDEREXECUTIONWOLE
  ADD CONSTRAINT BACKORDEREXECUTIONWOLE_CHECK1
  CHECK ((SHIPTO=1 AND SHIPTOSTOCKROOM_ID IS NOT NULL) OR (SHIPTO <> 1 AND SHIPTOSTOCKROOM_ID IS NULL));
  
ALTER TABLE BACKORDEREXECUTIONWOLE
  ADD CONSTRAINT BACKORDEREXECUTIONWOEL_CHECK2
  CHECK ((SHIPTO=2 AND DELIVERYPOINT_ID IS NOT NULL) OR (SHIPTO <> 2 AND DELIVERYPOINT_ID IS NULL));