-- this script updates the TASKANA database schema from version 6.2.0 to version 7.0.0.
SET SCHEMA %schemaName%;

INSERT INTO TASKANA_SCHEMA_VERSION (ID, VERSION, CREATED)
VALUES (TASKANA_SCHEMA_VERSION_ID_SEQ.NEXTVAL, '7.0.0', CURRENT_TIMESTAMP);

CREATE TABLE PERMISSION_INFO
(
    USER_ID     VARCHAR(32) NOT NULL,
    PERMISSION_ID    VARCHAR(256) NOT NULL,
    PRIMARY KEY (USER_ID, PERMISSION_ID)
);

ALTER TABLE WORKBASKET
    ADD COLUMN CUSTOM_5 VARCHAR(255) NULL
    ADD COLUMN CUSTOM_6 VARCHAR(255) NULL
    ADD COLUMN CUSTOM_7 VARCHAR(255) NULL
    ADD COLUMN CUSTOM_8 VARCHAR(255) NULL;

CREATE INDEX IDX_TASK_ID_HISTORY_EVENT ON TASK_HISTORY_EVENT
    (TASK_ID ASC)
    ALLOW REVERSE SCANS COLLECT SAMPLED DETAILED STATISTICS;
COMMIT WORK ;