-- ABS-36845/ ABS-64438

-- SYSTEMUSERAPPDEFAULTS table --
CREATE TABLE SYSTEMUSERAPPDEFAULTS
(
  SYSTEMUSER_ID          NUMBER NOT NULL,
  LEFTHANDEDOPERATION    VARCHAR2(1) NOT NULL CONSTRAINT YN_VALIDATIONFIELD413
                         CHECK (LEFTHANDEDOPERATION IN ('Y', 'N')),
  PIECESNOTBUNDLES       VARCHAR2(1) NOT NULL CONSTRAINT YN_VALIDATIONFIELD414
                         CHECK (PIECESNOTBUNDLES IN ('Y', 'N')),
  PRINTPARKEDSHEET       VARCHAR2(1) NOT NULL CONSTRAINT YN_VALIDATIONFIELD415
                         CHECK (PRINTPARKEDSHEET IN ('Y', 'N')),
  DEFAULTPLANTDEPT_ID    NUMBER NULL,
  UPDATEDBYSYSTEMUSER_ID NUMBER NOT NULL,
  TIMESTAMP              DATE NOT NULL
)
;

ALTER TABLE SYSTEMUSERAPPDEFAULTS
  ADD CONSTRAINT XPKSYSTEMUSERAPPDEFAULTS PRIMARY KEY (SYSTEMUSER_ID);

CREATE INDEX XIF1SYSTEMUSERAPPDEFAULTS ON SYSTEMUSERAPPDEFAULTS (DEFAULTPLANTDEPT_ID ASC);

ALTER TABLE SYSTEMUSERAPPDEFAULTS
  ADD CONSTRAINT SYSTEMUSERAPPDEFAULTS_PD FOREIGN KEY (DEFAULTPLANTDEPT_ID)
  REFERENCES PLANTDEPARTMENT (PLANTDEPARTMENT_ID) ON DELETE SET NULL;
