Skip to main content

Module branch

Module branch 

Source
Expand description

Ephemeral shadow branches.

The shadow source database — a Docker container’s init database, or the database named in shadow.url — is treated as a read-only baseline that pgmt never writes to. Each run works on a branch: a CREATE DATABASE ... TEMPLATE source copy that is dropped again at process exit. The source stays pristine by construction, every branch starts from the current baseline, and on external servers cleanup leaves things exactly as pgmt found them.

Functions§

admin_db_name
Maintenance database for CREATE/DROP DATABASE: those statements cannot run from the database being copied or dropped.
branch_url
Branch an external shadow.url source (declared reset: branch) and return the connection string for the branch. The named database itself is never touched.
cleanup_all_branches
Drop every branch this process created. Called at process exit, while any warm shadow containers are still running.
create_branch
Create an ephemeral branch of source_db and register it for drop at process exit. The source must have no active connections (PostgreSQL requires this of CREATE DATABASE ... TEMPLATE); pgmt itself never connects to it.
drop_branch
Drop the ephemeral branch a pool is connected to, reclaiming it as soon as a phase finishes instead of holding every branch until process exit.