-- ABS-155712 ORA-00060 deadlocks in Oracle production instance

ALTER TABLE MULTIREADSCANBATCHCONTENTS ADD (TIMEFRAMEINITIAL NUMBER DEFAULT (floor((floor((CAST(SYSTIMESTAMP AT TIME ZONE 'UTC' AS DATE) - to_date('01/01/2020', 'dd/mm/yyyy')) * 24 * 60) - 5) / 10) * 10 + 5) NOT NULL,
                                            TIMEFRAMEFINAL NUMBER DEFAULT (floor(floor((CAST(SYSTIMESTAMP AT TIME ZONE 'UTC' AS DATE) - to_date('01/01/2020', 'dd/mm/yyyy')) * 24 * 60) / 10) * 10) NOT NULL);

UPDATE MULTIREADSCANBATCHCONTENTS M
         SET M.TIMEFRAMEINITIAL = -M.MULTIREADSCANBATCH_ID, M.TIMEFRAMEFINAL = -M.MULTIREADSCANBATCH_ID;
COMMIT;
       
CREATE UNIQUE INDEX XAK1MULTIREADSCANBATCHCONTENTS ON MULTIREADSCANBATCHCONTENTS (IDCODE ASC, TIMEFRAMEINITIAL ASC);
CREATE UNIQUE INDEX XAK2MULTIREADSCANBATCHCONTENTS ON MULTIREADSCANBATCHCONTENTS (IDCODE ASC, TIMEFRAMEFINAL ASC);
