CREATE TABLE ERP_I_RENTALQTYADJUSTMENT
(
  TRANSFER_ID            NUMBER NOT NULL,
  TRANSFER_STATUS        NUMBER DEFAULT 0 NOT NULL,
  CUSTOMERNUMBER         NUMBER NOT NULL,
  DEPARTMENTNUMBER       NUMBER NOT NULL,
  CONSUMPTIONPOINTNUMBER NUMBER NOT NULL,
  PRODUCTCODE            VARCHAR2(12) NOT NULL,
  SIZECODE               VARCHAR2(12) NOT NULL,
  FINISHINGMETHODCODE    VARCHAR2(6) NOT NULL,
  ADJUSTMENTDATE         DATE NOT NULL,
  QUANTITY               NUMBER NOT NULL,
  REASONCODE             VARCHAR2(6) NOT NULL,
  REMARK                 VARCHAR2(1000),
  SALESEMPLOYEENUMBER1   NUMBER,
  SALESEMPLOYEENUMBER2   NUMBER,
  TIMESTAMP              DATE DEFAULT SYSDATE NOT NULL
);
COMMENT ON COLUMN ERP_I_RENTALQTYADJUSTMENT.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';
ALTER TABLE ERP_I_RENTALQTYADJUSTMENT
  ADD CONSTRAINT PK_ERP_I_RENTALQTYADJUSTMENT PRIMARY KEY (TRANSFER_ID);

CREATE TABLE ERP_I_RENTALQTYADJUSTMENT_LOG
(
  TRANSFER_ID     NUMBER NOT NULL,
  TRANSFER_STATUS NUMBER DEFAULT 0 NOT NULL,
  TEXT            VARCHAR2(1000),
  PROCESS_STATUS  NUMBER DEFAULT 0 NOT NULL,
  TIMESTAMP       DATE DEFAULT SYSDATE NOT NULL
);
COMMENT ON COLUMN ERP_I_RENTALQTYADJUSTMENT_LOG.TRANSFER_STATUS
  IS '0 = ready to be read, 1 = read correctly';
COMMENT ON COLUMN ERP_I_RENTALQTYADJUSTMENT_LOG.PROCESS_STATUS
  IS '0 = processed correctly, 1 = process stopped with errors';
ALTER TABLE ERP_I_RENTALQTYADJUSTMENT_LOG
  ADD CONSTRAINT PK_ERP_I_RENTALQTYADJUSTMENT_LOG PRIMARY KEY (TRANSFER_ID);
ALTER TABLE ERP_I_RENTALQTYADJUSTMENT_LOG
  ADD CONSTRAINT FK_ERP_I_RENTALQTYADJUSTMENT_LOG FOREIGN KEY (TRANSFER_ID)
  REFERENCES ERP_I_RENTALQTYADJUSTMENT(TRANSFER_ID) ON DELETE CASCADE;
