---
title: "Atualizando o Rest PKI Core da versão 3.x para 4.0"
description: "Passos adicionais para atualizar o Rest PKI Core de 3.x para 4.0, incluindo se é preciso criar antes, manualmente, índices do banco de dados em instâncias com milhões de registros."
canonical: "https://docs.lacunasoftware.com/articles/rest-pki/core/on-premises/update-40"
locale: "pt-BR"
product: "Rest PKI Core"
last_updated: "2026-10-12"
---

# Atualizando o Rest PKI Core da versão 3.x para 4.0

## 1. Decida se você precisa criar índices manualmente

Se a sua instância tem um **grande número de sessões de assinatura (Signature Sessions) ou transações (milhões)**, recomenda-se criar manualmente alguns dos índices exigidos pela versão 4.0 **antes de atualizar**, seguindo o passo 2.

Se a sua instância **não se enquadra nessas condições**, você pode pular o passo 2 e **seguir direto para o passo 3**.

## 2. Crie os índices manualmente

### Usando SQL Server

Execute os seguintes comandos no seu banco de dados SQL Server, um de cada vez, garantindo que cada comando termine com sucesso antes de executar o próximo.

```SQL
IF NOT EXISTS (
	SELECT 1 
	FROM sys.columns 
	WHERE [name] = 'DateSignaturesStartedUtc'
	  AND [object_id] = OBJECT_ID('SignatureSessions')
)
BEGIN
	ALTER TABLE [SignatureSessions] 
	ADD [DateSignaturesStartedUtc] datetime2 NULL;
END

IF NOT EXISTS (
	SELECT 1 FROM sys.indexes 
	WHERE name = 'IX_SignatureSessions_DateCompletedUtc_DateSignaturesStartedUtc'
	  AND object_id = OBJECT_ID('dbo.SignatureSessions')
)
CREATE INDEX [IX_SignatureSessions_DateCompletedUtc_DateSignaturesStartedUtc]
ON [SignatureSessions] ([DateCompletedUtc], [DateSignaturesStartedUtc]);

IF NOT EXISTS (
	SELECT 1 FROM sys.indexes 
	WHERE name = 'IX_SignatureSessions_DateCreatedUtc_DateCompletedUtc'
	  AND object_id = OBJECT_ID('dbo.SignatureSessions')
)
CREATE INDEX [IX_SignatureSessions_DateCreatedUtc_DateCompletedUtc]
ON [SignatureSessions] ([DateCreatedUtc], [DateCompletedUtc]);

IF NOT EXISTS (
	SELECT 1 FROM sys.indexes 
	WHERE name = 'IX_SignatureSessions_StatusCode_DateCreatedUtc'
	  AND object_id = OBJECT_ID('dbo.SignatureSessions')
)
CREATE INDEX [IX_SignatureSessions_StatusCode_DateCreatedUtc]
ON [SignatureSessions] ([StatusCode], [DateCreatedUtc]);

IF NOT EXISTS (
	SELECT 1 FROM sys.indexes 
	WHERE name = 'IX_SignatureSessions_SubscriptionId_DateCreatedUtc'
	  AND object_id = OBJECT_ID('dbo.SignatureSessions')
)
CREATE INDEX [IX_SignatureSessions_SubscriptionId_DateCreatedUtc]
ON [SignatureSessions] ([SubscriptionId], [DateCreatedUtc]);

IF NOT EXISTS (
	SELECT 1 FROM sys.indexes 
	WHERE name = 'IX_SignatureSessions_SubscriptionId_StatusCode_DateCreatedUtc'
	  AND object_id = OBJECT_ID('dbo.SignatureSessions')
)
CREATE INDEX [IX_SignatureSessions_SubscriptionId_StatusCode_DateCreatedUtc]
ON [SignatureSessions] ([SubscriptionId], [StatusCode], [DateCreatedUtc]);

IF NOT EXISTS (
	SELECT 1 FROM sys.indexes 
	WHERE name = 'IX_Documents_DateCreatedUtc'
	  AND object_id = OBJECT_ID('dbo.Documents')
)
CREATE INDEX [IX_Documents_DateCreatedUtc]
ON [Documents] ([DateCreatedUtc]);

IF NOT EXISTS (
	SELECT 1 FROM sys.indexes 
	WHERE name = 'IX_Documents_SubscriptionId_DateCreatedUtc'
	  AND object_id = OBJECT_ID('dbo.Documents')
)
CREATE INDEX [IX_Documents_SubscriptionId_DateCreatedUtc]
ON [Documents] ([SubscriptionId], [DateCreatedUtc]);
```

### Usando PostgreSQL

Execute os seguintes comandos no seu banco de dados PostgreSQL, um de cada vez, garantindo que cada comando termine com sucesso antes de executar o próximo.

```SQL

ALTER TABLE "SignatureSessions" ADD COLUMN IF NOT EXISTS "DateSignaturesStartedUtc" timestamptz DEFAULT NULL;

CREATE INDEX IF NOT EXISTS "IX_SignatureSessions_DateCompletedUtc_DateSignaturesStartedUtc" ON "SignatureSessions" ("DateCompletedUtc", "DateSignaturesStartedUtc");

CREATE INDEX IF NOT EXISTS "IX_SignatureSessions_DateCreatedUtc_DateCompletedUtc" ON "SignatureSessions" ("DateCreatedUtc", "DateCompletedUtc");

CREATE INDEX IF NOT EXISTS "IX_SignatureSessions_StatusCode_DateCreatedUtc" ON "SignatureSessions" ("StatusCode", "DateCreatedUtc");

CREATE INDEX IF NOT EXISTS "IX_SignatureSessions_SubscriptionId_DateCreatedUtc" ON "SignatureSessions" ("SubscriptionId", "DateCreatedUtc");

CREATE INDEX IF NOT EXISTS "IX_SignatureSessions_SubscriptionId_StatusCode_DateCreatedUtc" ON "SignatureSessions" ("SubscriptionId", "StatusCode", "DateCreatedUtc");

CREATE INDEX IF NOT EXISTS "IX_Documents_DateCreatedUtc" ON "Documents" ("DateCreatedUtc");

CREATE INDEX IF NOT EXISTS "IX_Documents_SubscriptionId_DateCreatedUtc" ON "Documents" ("SubscriptionId", "DateCreatedUtc");
```

## 3. Atualize o Rest PKI Core

Prossiga com as instruções de atualização padrão:
- [Docker](https://docs.lacunasoftware.com/articles/rest-pki/core/on-premises/docker): atualize para a imagem `lacunasoftware/restpkicore:4.1`.
- [Linux](https://docs.lacunasoftware.com/articles/rest-pki/core/on-premises/linux/update)
