--ABS-142975
CREATE TABLE ERP_CLEANUP_SELECTION
(
  ERP_CLEANUP_SELECTION_ID NUMBER NOT NULL,
  TABLENAME                VARCHAR2(30) NOT NULL,
  LOGTABLENAME             VARCHAR2(30) NULL,
  DESCRIPTION              VARCHAR2(40) NOT NULL,
  DATEFIELDNAME            VARCHAR2(30) NOT NULL,
  EXTRA_WHERE_CLAUSE       VARCHAR2(144) NULL,
  DAYS_TO_KEEP             NUMBER DEFAULT 3 NOT NULL,
  TIMESTAMP                DATE DEFAULT SYSDATE NOT NULL,
  SYSTEMUSER_ID            NUMBER DEFAULT 0 NOT NULL 
);
COMMENT ON COLUMN ERP_CLEANUP_SELECTION.DATEFIELDNAME
  IS 'Name of the field where the date is stored';
ALTER TABLE ERP_CLEANUP_SELECTION
  ADD CONSTRAINT PK_ERP_CLEANUP_SELECTION PRIMARY KEY (ERP_CLEANUP_SELECTION_ID);
ALTER TABLE ERP_CLEANUP_SELECTION
  ADD CONSTRAINT PK2_ERP_CLEANUP_SELECTION UNIQUE (TABLENAME);
ALTER TABLE ERP_CLEANUP_SELECTION
  ADD CONSTRAINT CHK_ERP_CLEANUP_SELECTION_DAY
  CHECK (DAYS_TO_KEEP >= 3);  
