Skip to content

Audit history is stored separately from your upstream PostgreSQL. Use the PgStack database connection details in your project settings to connect with psql, a PostgreSQL client, or your application's ORM.

Changes performed by creating, updating, or deleting each row are stored in a table called changes and have the following structure:

Column Type Description
id uuid A unique identifier of the change record
database varchar(255) Database name where the changed record was stored
schema varchar(255) Schema name where the changed record was stored
table varchar(255) Table name where the changed record was stored
primary_key varchar(255) A unique identifier of the changed record (optional)
operation text Enum that can be either CREATE, UPDATE, or DELETE
before jsonb Record's values before the change
after jsonb Record's values after the change
context jsonb App context passed by using our recommended ORM packages
committed_at timestamptz(0) When the record was changed
queued_at timestamptz(0) When the changed record was ingested from WAL
created_at timestamptz(0) When the change record was stored in the database
transaction_id bigint PostgreSQL transaction ID
position bigint PostgreSQL WAL position

You can query changes by using our ORM packages or by directly connecting and executing SQL queries. For example, if you need to find when and how a user record with ID b7267340-5011-40f4-ab9a-902b68fc5b25 had its email updated to new@example.com in the last 3 months:

SELECT *
FROM "changes"
WHERE
"database" = 'postgres' AND "schema" = 'public' AND "table" = 'users' AND
"primary_key" = 'b7267340-5011-40f4-ab9a-902b68fc5b25' AND "operation" = 'UPDATE' AND
"after" @> '{"email": "new@example.com"}' AND NOT ("before" @> '{"email": "new@example.com"}') AND
"committed_at" BETWEEN (NOW() - INTERVAL '3 months') AND NOW()
LIMIT 1;

Use an application connection pool and reuse connections rather than opening a connection per query. Configure the connection endpoint and limits using the details provided in your project settings.

You can restrict access to your PgStack database by IP address in your project settings using CIDR notation. Allow the addresses used by your application servers, VPN, office, or home network.

By default, the database has a single 0.0.0.0/0 rule, which allows connections from any IP address.

The PgStack database uses TLS/SSL to encrypt connections and authenticate both the server and client. Its certificate authority (CA) and certificates are managed and renewed automatically.