On this page
Postgres History Support
To reduce the burden on NATS Key Value Store, we recommend for larger processes using Postgres.
To enable this feature, first add the infrastructure to your Postgress database:
Changing the history store needs a fresh installation. Data loss can occur from changing an existing installation
create user shar_user with password 'shar_user';
create database shar_db;
\c shar_db;
create schema shar_store;
create table shar_store.history
(
id bigint generated by default as identity,
ns varchar(255) not null,
processinstanceid char(27) not null,
trackingid char(27) not null,
entrytype integer not null,
elementid varchar(255) not null,
compensable boolean not null,
compensating boolean not null,
state bytea not null,
timestamp bigint not null,
primary key (id)
);
alter table shar_store.history
owner to shar_user;
create index idx_shar_history_element
on shar_store.history (ns, processinstanceid, elementid, entrytype);
create index idx_shar_history_process_tracking
on shar_store.history (ns, processinstanceid, trackingid);Then set the following environment variables when starting the server (connection string is just an example):
HistoryStore=postgres
HistoryStoreConnection='postgres://shar_user:shar_user@localhost:5432/shar_db?sslmode=disable'