DO $$ 
    BEGIN
        BEGIN
           IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Build">=1765) THEN
		RETURN;
          END IF;
CREATE INDEX "IDX_UserAccessRights_EntityId-EntityType-OwnerId"
    ON public."UserAccessRights" USING btree
    ("EntityId" ASC NULLS LAST,"EntityType" ASC NULLS LAST,"OwnerId" ASC NULLS LAST)
    TABLESPACE pg_default; 

CREATE INDEX "IDX_RoleAccessRights_EntityId-EntityType-OwnerId"
    ON public."RoleAccessRights" USING btree
    ("EntityId" ASC NULLS LAST,"EntityType" ASC NULLS LAST,"OwnerId" ASC NULLS LAST)
    TABLESPACE pg_default; 

        EXCEPTION
            WHEN duplicate_column THEN RAISE NOTICE 'index <UserAccessRights_EntityId-EntityType>.';
        END;
    END;
$$
