Minipg packages PostgreSQL, a relational database applications use to store data, into a single executable. It starts a local PostgreSQL server and keeps the database files in a .pgdb directory. For local development or continuous integration (CI), that means you can start a fresh test database without installing a separate PostgreSQL service or running a Docker container. Minipg v0.3 manual
Maintainer Jeff Lindsay announced Minipg v0.3 on November 17, 2026. The previous version ran PostgreSQL through the v86 emulator inside a hidden browser window. Version 0.3 bundles PostgreSQL 18 from the official Alpine-based image and runs it through hyper9. Hyper9 handles requests PostgreSQL would normally send to Linux, such as opening a file. Minipg supplies the database program and the files it needs directly, so Docker can stay out of the test job. The release drew fresh discussion on Hacker News on November 26. Lindsay’s announcement, v0.3 release notes, Hacker News discussion
On Linux x86_64, the documented path requires kernel 5.11 or later and works without KVM, Linux’s hardware virtualization interface. On Linux arm64, Minipg requires access to /dev/kvm. On a compatible runner, minipg run starts the server, gives the test command its connection settings and returns that command’s exit status. That matters for database migrations, which change the database structure. A failing migration command can fail the CI job just as it would with a separately installed database. Minipg v0.3 manual
Lindsay describes hyper9 as a research prototype and advises using data you can recreate. The bundled database runs with PostgreSQL’s optional just-in-time query optimization disabled and can load only extensions included in its image. The manual shows how to start the database on a compatible runner. Your app’s driver, extensions and migration files still need a test of their own. v0.3 release notes, bundled image limits
How to test Minipg with your PostgreSQL migrations
If you already test PostgreSQL migrations in CI, add a parallel Minipg job on a disposable Linux runner. Use the same SQL and client in both jobs to check whether each server accepts a connection, applies the change, enforces a constraint and reports an intentional SQL error. Keep the conventional job for checks that depend on your production settings, extensions or permissions.
Check the runner and pin both builds
Run uname -m and uname -r on the runner. For this test, use x86_64 and Linux 5.11 or later. Download minipg_0.3_linux_amd64.zip from the v0.3 release, check its SHA-256 against the release metadata and put the extracted minipg executable on PATH. Make the same build of the psql client available to both jobs. v0.3 release assets, release asset metadata
Run minipg versions to identify the bundled PostgreSQL release and source image. The tested build reported PostgreSQL 18.6 and the Linux amd64 image manifest sha256:300ebd02c6d4de9ee27ad7f6855d5d21b4d3a4a5117767c1197d284c635d9736. If your conventional job runs a Docker service, you can pin it to postgres@ followed by that digest. A conventional installation of the same patch release also works as a baseline if you record any package differences. Minipg removes some files from the source image and sets some server options itself. One of those is jit=off, which disables just-in-time compilation, the optional optimization that turns parts of a query into machine code. Minipg version and image documentation, PostgreSQL 18.6 Alpine tag metadata
Apply the same migration and check the schema
Save this as migration.sql. It creates a delivery-attempt table that requires a positive attempt count.
CREATE TABLE public.delivery_attempt (
id bigint PRIMARY KEY,
attempt_count integer NOT NULL,
CONSTRAINT delivery_attempt_count_positive CHECK (attempt_count > 0)
);
Save this as assert.sql. It checks that the named constraint exists and is validated. It also checks that the server accepts a count of 1 and rejects 0 with a check-constraint violation.
DO $$
BEGIN
IF NOT EXISTS (
SELECT FROM pg_constraint
WHERE conrelid = 'public.delivery_attempt'::regclass
AND conname = 'delivery_attempt_count_positive'
AND contype = 'c' AND convalidated
) THEN
RAISE EXCEPTION 'expected validated check constraint';
END IF;
INSERT INTO public.delivery_attempt VALUES (1, 1);
BEGIN
INSERT INTO public.delivery_attempt VALUES (2, 0);
RAISE EXCEPTION 'zero attempts accepted';
EXCEPTION WHEN check_violation THEN
NULL;
END;
END
$$;
Save this as check.sh. The first queries record the running server’s version and JIT setting, the connected database’s encoding and locale, and the current role. In the locale output, b means PostgreSQL’s built-in locale provider and c means the system C library. Read the built-in provider’s locale from datlocale and the C library’s sorting locale from datcollate. The -X flag skips local psql startup files, and ON_ERROR_STOP stops the script on a SQL error. The wrapper saves the migration’s exit status before printing its summary. If the migration fails, the wrapper returns that status before reaching the schema check. PostgreSQL 18 psql, database catalog, character set support
#!/bin/sh
set -eu
psql -X -At -v ON_ERROR_STOP=1 -c 'SHOW server_version'
psql -X -At -v ON_ERROR_STOP=1 -c 'SHOW jit'
psql -X -At -v ON_ERROR_STOP=1 -c 'SHOW server_encoding'
psql -X -At -v ON_ERROR_STOP=1 -c "
SELECT datlocprovider, datcollate, datlocale,
current_user, current_setting('is_superuser')
FROM pg_database WHERE datname = current_database()
"
printf '%s\n' 'stage=startup outcome=connected'
rc=0
psql -X -v ON_ERROR_STOP=1 -f "$1" || rc=$?
printf 'stage=migration exit=%s\n' "$rc"
[ "$rc" -eq 0 ] || exit "$rc"
psql -X -v ON_ERROR_STOP=1 -f assert.sql
printf '%s\n' 'stage=schema outcome=passed'
From a fresh workspace with all three files, run minipg run ./pass.pgdb -- sh check.sh migration.sql. In the conventional job, point its connection settings to an empty, disposable test database and run sh check.sh migration.sql.
Check that a SQL error reaches CI
Save this as broken.sql. The table is deliberately missing, so the migration fails after the connection succeeds.
ALTER TABLE public.delivery_attempt_missing ADD COLUMN retry_at timestamptz;
Run minipg run ./fail.pgdb -- sh check.sh broken.sql and run sh check.sh broken.sql against a second empty database in the conventional job. Capture each outer command’s status before any reporting step. PostgreSQL documents status 3 for a SQL script error with ON_ERROR_STOP enabled. For this test, check that the connection succeeded, the migration reported 3, the outer command returned 3 and the schema check never ran. A startup or connection problem can also produce a nonzero status. PostgreSQL 18 psql exit statuses
All four runs used the same PostgreSQL 18.6 psql client on Linux x86_64 without KVM. The conventional server ran directly on Linux with binaries from the same Alpine image. Its database cluster was initialized with initdb --locale=C. Both servers reported PostgreSQL 18.6 and jit=off.
| Setting or result | Minipg v0.3 | Conventional PostgreSQL |
|---|---|---|
| Database locale | C.UTF-8 (PostgreSQL built-in provider) |
C (system C library) |
SHOW server_encoding |
UTF8 |
SQL_ASCII |
| Current role | postgres (superuser) |
postgres (superuser) |
| Valid migration | Outer exit 0, schema check passed |
Outer exit 0, schema check passed |
| Missing-table migration | Outer exit 3, schema check skipped |
Outer exit 3, schema check skipped |
The fixture only checks integer values, so it leaves text sorting and non-ASCII data untested. PostgreSQL treats high-bit bytes as uninterpreted under SQL_ASCII. If your app stores non-ASCII text, use a conventional test database with the same encoding and locale as production, then check that representative text survives a write and read through your app’s driver. Add an assertion for the expected sort order if your app relies on it. PostgreSQL 18 character set support
minipg run supplies the database superuser’s connection settings by default. A superuser can pass checks that would fail under a restricted role. Follow the smoke test with your real migrations and an application startup check using the roles they normally run under. Minipg v0.3 manual
If the jobs disagree, look at the last stage each reached. If a job never connects, check the runner and database startup. After a successful connection, read the first SQL error and check any permissions or extensions it names. If the migration succeeds and the schema check fails, inspect what the migration created.
Compare CI stage records in Fluxtail
When the two jobs run separately, they can send small JSON summaries to the same Fluxtail test stream. Give both jobs a shared marker unique to that comparison. Put the marker, database variant, stage and result in each message. Build the messages from known stage names and command outcomes. Keep raw SQL output, connection strings, credentials and data values out of the events.
These two synthetic JSON records represent the deliberate failure, one record per request.
{"message":"pg-ci-8472 engine=minipg stage=migration exit=3"}
{"message":"pg-ci-8472 engine=conventional stage=migration exit=3"}
Send each record as a JSON POST to the exact HTTPS URL of an active HTTP JSON receiver. Use its receiver-bound ingest:write Bearer token from CI secret storage. HTTP 202 means the receiver accepted the event for processing. To verify delivery, open the test stream in Live Tail around the run time and filter message text for pg-ci-8472. The rows show which stage each job reported. Judge the database test by its SQL assertions and exit statuses. HTTP JSON ingestion example, Live Tail message filters