Skip to content

๐Ÿงฉ Postgres Extensions

SuperStack supports PostgreSQL extensions, letting you add powerful features like cryptographic functions or JWT handling.

๐Ÿ”Œ Loading a Built-In Extension

To load a standard extension (like pgcrypto), create a migration file such as:

-- File: postgres/migrations/01-extensions.sql

create extension pgcrypto;

โš ๏ธ create extension is non-transactional, so donโ€™t wrap this file in BEGIN/COMMIT.

๐Ÿ› ๏ธ Building an Extension from Source

Some extensions (like pgjwt) must be compiled manually.

1. Clone the Extension Source

git clone https://github.com/michelp/pgjwt postgres/pgjwt

2. Modify the Postgres Dockerfile

Edit postgres/Dockerfile to install build tools and compile the extension:

RUN apt-get update && apt-get install -y \
    build-essential \
    postgresql-server-dev-17

# pgjwt - used by the auth schema
COPY ./pgjwt /pgjwt
WORKDIR /pgjwt
RUN make && make install

# Reset workdir
WORKDIR /var/lib/postgresql

๐Ÿงผ Set WORKDIR back to the default to avoid unintended effects.

3. Rebuild the Container

docker compose build postgres

Thatโ€™s it โ€” the extension is now available to load in your migrations.