<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Documentation on pgmi</title><link>https://vvka-141.github.io/pgmi/docs/</link><description>Recent content in Documentation on pgmi</description><generator>Hugo</generator><language>en</language><atom:link href="https://vvka-141.github.io/pgmi/docs/index.xml" rel="self" type="application/rss+xml"/><item><title>Overview</title><link>https://vvka-141.github.io/pgmi/docs/readme/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/readme/</guid><description>&lt;h1 id="pgmi-documentation"&gt;pgmi Documentation&lt;a class="anchor" href="#pgmi-documentation"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;pgmi is a PostgreSQL-native deployment tool that loads your project files into session temp tables and lets your &lt;code&gt;deploy.sql&lt;/code&gt; drive everything — transactions, execution order, and logic. These docs cover the session API, CLI, deployment patterns, testing, security, and operational guides.&lt;/p&gt;
&lt;h2 id="recommended-reading-order"&gt;Recommended Reading Order&lt;a class="anchor" href="#recommended-reading-order"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;New to pgmi?&lt;/strong&gt; Start here:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://vvka-141.github.io/pgmi/docs/quickstart/"&gt;Quickstart&lt;/a&gt;
 — Deploy your first project&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vvka-141.github.io/pgmi/docs/why-pgmi/"&gt;Why pgmi&lt;/a&gt;
 — Understand the philosophy&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vvka-141.github.io/pgmi/docs/session-api/"&gt;Session API&lt;/a&gt;
 — Learn the session API&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vvka-141.github.io/pgmi/docs/tradeoffs/"&gt;Trade-offs&lt;/a&gt;
 — Understand the honest costs&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Migrating from another tool?&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Why pgmi</title><link>https://vvka-141.github.io/pgmi/docs/why-pgmi/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/why-pgmi/</guid><description>&lt;h1 id="why-pgmi"&gt;Why pgmi?&lt;a class="anchor" href="#why-pgmi"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;pgmi takes a different approach to database deployments. This document explains when that approach makes sense—and when it doesn&amp;rsquo;t.&lt;/p&gt;
&lt;h2 id="the-core-idea"&gt;The core idea&lt;a class="anchor" href="#the-core-idea"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Most deployment tools work like this:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Your files → Tool decides order → Tool decides transactions → Database&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;pgmi works like this:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Your files → PostgreSQL temp tables → YOUR deploy.sql decides everything → Database&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The difference: &lt;strong&gt;you write the deployment logic in SQL, not configuration.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id="a-concrete-example"&gt;A concrete example&lt;a class="anchor" href="#a-concrete-example"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Suppose you need environment-specific deployment behavior:&lt;/p&gt;</description></item><item><title>Quickstart</title><link>https://vvka-141.github.io/pgmi/docs/quickstart/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/quickstart/</guid><description>&lt;h1 id="getting-started-with-pgmi"&gt;Getting Started with pgmi&lt;a class="anchor" href="#getting-started-with-pgmi"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;This guide takes you from zero to a working deployment in about 10 minutes. The commands are concrete — the only values you supply are your local PostgreSQL password and the database name.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you&amp;rsquo;ll do:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install pgmi&lt;/li&gt;
&lt;li&gt;Make sure PostgreSQL is reachable&lt;/li&gt;
&lt;li&gt;Create a project&lt;/li&gt;
&lt;li&gt;Deploy it&lt;/li&gt;
&lt;li&gt;Verify the deployment&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;What you need:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;PostgreSQL running on &lt;code&gt;localhost:5432&lt;/code&gt; (the default), reachable over a &lt;strong&gt;direct connection&lt;/strong&gt; or a session-mode pooler — transaction-mode poolers (PgBouncer txn mode, RDS Proxy) break pgmi&amp;rsquo;s session temp tables; see &lt;a href="https://vvka-141.github.io/pgmi/docs/production/#connection-requirements"&gt;Connection Requirements&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A PostgreSQL user with database creation rights (typically &lt;code&gt;postgres&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;No Go toolchain required — the quickstart installs a prebuilt binary. (Installing from source with &lt;code&gt;go install&lt;/code&gt; is an optional alternative; see Step 1.)&lt;/p&gt;</description></item><item><title>Coming from other tools</title><link>https://vvka-141.github.io/pgmi/docs/coming-from/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/coming-from/</guid><description>&lt;h1 id="coming-from-other-tools"&gt;Coming from Other Tools&lt;a class="anchor" href="#coming-from-other-tools"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;This guide helps you migrate to pgmi from other database deployment tools. Each section maps familiar concepts to pgmi equivalents and shows a concrete migration path.&lt;/p&gt;
&lt;blockquote class='book-hint '&gt;
&lt;p&gt;&lt;strong&gt;How pgmi deploys:&lt;/strong&gt; The &lt;code&gt;deploy.sql&lt;/code&gt; examples below query files from &lt;code&gt;pg_temp.pgmi_plan_view&lt;/code&gt; (or &lt;code&gt;pg_temp.pgmi_source_view&lt;/code&gt;) and execute them directly with &lt;code&gt;EXECUTE&lt;/code&gt;. See &lt;a href="https://vvka-141.github.io/pgmi/docs/session-api/"&gt;Session API&lt;/a&gt;
 for the full reference.&lt;/p&gt;
&lt;/blockquote&gt;&lt;h2 id="quick-concept-mapping"&gt;Quick concept mapping&lt;a class="anchor" href="#quick-concept-mapping"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Concept&lt;/th&gt;
					&lt;th&gt;Flyway&lt;/th&gt;
					&lt;th&gt;Liquibase&lt;/th&gt;
					&lt;th&gt;pgmi&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;Migration files&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;V1__name.sql&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;Changelog + changesets&lt;/td&gt;
					&lt;td&gt;Any &lt;code&gt;.sql&lt;/code&gt; file&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Execution order&lt;/td&gt;
					&lt;td&gt;Filename prefix (V1, V2&amp;hellip;)&lt;/td&gt;
					&lt;td&gt;Changelog order&lt;/td&gt;
					&lt;td&gt;Your &lt;code&gt;deploy.sql&lt;/code&gt; decides&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Transaction control&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;flyway.group=true&lt;/code&gt; (batch)&lt;/td&gt;
					&lt;td&gt;Per-changeset or global&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;BEGIN&lt;/code&gt;/&lt;code&gt;COMMIT&lt;/code&gt; in deploy.sql&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Tracking state&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;flyway_schema_history&lt;/code&gt; table&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;databasechangelog&lt;/code&gt; table&lt;/td&gt;
					&lt;td&gt;Your choice (or none)&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Rollback&lt;/td&gt;
					&lt;td&gt;Undo scripts (&lt;code&gt;U1__name.sql&lt;/code&gt;)&lt;/td&gt;
					&lt;td&gt;Rollback commands in changeset&lt;/td&gt;
					&lt;td&gt;PostgreSQL transactions&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Conditionals&lt;/td&gt;
					&lt;td&gt;Callbacks, limited&lt;/td&gt;
					&lt;td&gt;Preconditions, contexts&lt;/td&gt;
					&lt;td&gt;Full PL/pgSQL in deploy.sql&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Configuration&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;flyway.conf&lt;/code&gt; / &lt;code&gt;flyway.toml&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;liquibase.properties&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;pgmi.yaml&lt;/code&gt;&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="coming-from-flyway"&gt;Coming from Flyway&lt;a class="anchor" href="#coming-from-flyway"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id="what-changes"&gt;What changes&lt;a class="anchor" href="#what-changes"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Before (Flyway):&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>CLI reference</title><link>https://vvka-141.github.io/pgmi/docs/cli/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/cli/</guid><description>&lt;h1 id="cli-reference"&gt;CLI Reference&lt;a class="anchor" href="#cli-reference"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Complete reference for all pgmi commands. Every example is copy-paste ready.&lt;/p&gt;
&lt;p&gt;For a guided walkthrough, see &lt;a href="https://vvka-141.github.io/pgmi/docs/quickstart/"&gt;Quickstart&lt;/a&gt;
.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="global-flags"&gt;Global Flags&lt;a class="anchor" href="#global-flags"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;These flags work with every command:&lt;/p&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Flag&lt;/th&gt;
					&lt;th&gt;Description&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;-v, --verbose&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;Enable verbose output (also shows PostgreSQL &lt;code&gt;RAISE DEBUG&lt;/code&gt; messages)&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;-h, --help&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;Show help for any command&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;hr&gt;
&lt;h2 id="pgmi-deploy"&gt;pgmi deploy&lt;a class="anchor" href="#pgmi-deploy"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Execute a database deployment.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pgmi deploy &amp;lt;project_path&amp;gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;flags&lt;span style="color:#f92672"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;pgmi connects to PostgreSQL, loads your project files into session temp tables, then runs &lt;code&gt;deploy.sql&lt;/code&gt; which directly executes your files.&lt;/p&gt;</description></item><item><title>Connections</title><link>https://vvka-141.github.io/pgmi/docs/connections/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/connections/</guid><description>&lt;h1 id="connection-architecture"&gt;Connection Architecture&lt;a class="anchor" href="#connection-architecture"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;How pgmi connects to every PostgreSQL target — from localhost to multi-cloud managed services.&lt;/p&gt;
&lt;p&gt;For CLI flag details, see &lt;a href="https://vvka-141.github.io/pgmi/docs/cli/#connection-flags"&gt;CLI reference&lt;/a&gt;
. For CI/CD pipeline examples, see &lt;a href="https://vvka-141.github.io/pgmi/docs/production/#cicd-patterns"&gt;Production&lt;/a&gt;
.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="connection-provider-factory"&gt;Connection provider factory&lt;a class="anchor" href="#connection-provider-factory"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;pgmi resolves CLI flags and environment variables into a concrete connector at startup:&lt;/p&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Auth method&lt;/th&gt;
					&lt;th&gt;Connector&lt;/th&gt;
					&lt;th&gt;How tokens work&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;Standard&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;StandardConnector&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;Username/password via pgx, with retry (3 attempts, exponential backoff)&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Azure Entra ID&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;TokenBasedConnector&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;azidentity.NewDefaultAzureCredential&lt;/code&gt; chain, OAuth token as password&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;AWS IAM&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;TokenBasedConnector&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;rds/auth.BuildAuthToken&lt;/code&gt; via default AWS credential chain&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Google Cloud SQL IAM&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;GoogleCloudSQLConnector&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;cloud.google.com/go/cloudsqlconn&lt;/code&gt; with IAM auth and internal TLS&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;All providers produce a &lt;code&gt;*pgx.Conn&lt;/code&gt; — the rest of pgmi doesn&amp;rsquo;t know or care which auth method was used.&lt;/p&gt;</description></item><item><title>Configuration</title><link>https://vvka-141.github.io/pgmi/docs/configuration/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/configuration/</guid><description>&lt;h1 id="configuration-reference-pgmiyaml"&gt;Configuration Reference (pgmi.yaml)&lt;a class="anchor" href="#configuration-reference-pgmiyaml"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;h2 id="overview"&gt;Overview&lt;a class="anchor" href="#overview"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;pgmi.yaml&lt;/code&gt; is an optional project-level configuration file that stores connection defaults and parameters. Place it in your project root (next to &lt;code&gt;deploy.sql&lt;/code&gt;) to enable zero-flag deployments:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Instead of:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pgmi deploy . --database myapp --param env&lt;span style="color:#f92672"&gt;=&lt;/span&gt;development
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Just:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pgmi deploy .&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;pgmi init&lt;/code&gt; generates a &lt;code&gt;pgmi.yaml&lt;/code&gt; automatically for both templates.&lt;/p&gt;
&lt;h2 id="coming-from-other-tools"&gt;Coming from Other Tools&lt;a class="anchor" href="#coming-from-other-tools"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Tool&lt;/th&gt;
					&lt;th&gt;Config File&lt;/th&gt;
					&lt;th&gt;pgmi Equivalent&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;Flyway&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;flyway.conf&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;pgmi.yaml&lt;/code&gt;&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;.NET EF Core&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;appsettings.json&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;pgmi.yaml&lt;/code&gt;&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Prisma&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;schema.prisma&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;pgmi.yaml&lt;/code&gt;&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Liquibase&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;liquibase.properties&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;pgmi.yaml&lt;/code&gt;&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;Key difference:&lt;/strong&gt; pgmi.yaml configures the &lt;em&gt;runner&lt;/em&gt; (connection, parameters, timeout). Deployment logic lives in &lt;code&gt;deploy.sql&lt;/code&gt;, not in configuration.&lt;/p&gt;</description></item><item><title>deploy.sql guide</title><link>https://vvka-141.github.io/pgmi/docs/deploy-guide/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/deploy-guide/</guid><description>&lt;h1 id="deploysql-authoring-guide"&gt;deploy.sql Authoring Guide&lt;a class="anchor" href="#deploysql-authoring-guide"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;This guide covers patterns for writing &lt;code&gt;deploy.sql&lt;/code&gt; — from basic file execution to data ingestion, environment branching, and multi-phase deployments. Every example is copy-paste ready.&lt;/p&gt;
&lt;p&gt;For the session API reference (views, columns, functions), see &lt;a href="https://vvka-141.github.io/pgmi/docs/session-api/"&gt;Session API&lt;/a&gt;
.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="the-basic-pattern"&gt;The basic pattern&lt;a class="anchor" href="#the-basic-pattern"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Your &lt;code&gt;deploy.sql&lt;/code&gt; queries files from session views and executes them with &lt;code&gt;EXECUTE&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;BEGIN&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;DO&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;$$&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;DECLARE&lt;/span&gt; v_file RECORD;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;BEGIN&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;FOR&lt;/span&gt; v_file &lt;span style="color:#66d9ef"&gt;IN&lt;/span&gt; (
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;SELECT&lt;/span&gt; path, content
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;FROM&lt;/span&gt; pg_temp.pgmi_source_view
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;WHERE&lt;/span&gt; directory &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;./migrations/&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;AND&lt;/span&gt; is_sql_file
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;ORDER&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;BY&lt;/span&gt; path
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ) LOOP
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; RAISE NOTICE &lt;span style="color:#e6db74"&gt;&amp;#39;Executing: %&amp;#39;&lt;/span&gt;, v_file.path;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;EXECUTE&lt;/span&gt; v_file.content;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;END&lt;/span&gt; LOOP;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;END&lt;/span&gt; &lt;span style="color:#960050;background-color:#1e0010"&gt;$$&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;COMMIT&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Use &lt;code&gt;pgmi_plan_view&lt;/code&gt; instead of &lt;code&gt;pgmi_source_view&lt;/code&gt; when you want metadata-driven ordering via &lt;code&gt;&amp;lt;pgmi-meta&amp;gt;&lt;/code&gt; blocks. See &lt;a href="https://vvka-141.github.io/pgmi/docs/session-api/#which-view-should-i-use"&gt;Session API&lt;/a&gt;
.&lt;/p&gt;</description></item><item><title>Script metadata</title><link>https://vvka-141.github.io/pgmi/docs/metadata/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/metadata/</guid><description>&lt;h1 id="script-metadata-guide"&gt;Script Metadata Guide&lt;a class="anchor" href="#script-metadata-guide"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;pgmi supports optional XML metadata blocks in SQL files that control deployment behavior: path-independent tracking, idempotency control, and explicit execution ordering.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="metadata-is-optional"&gt;Metadata is Optional&lt;a class="anchor" href="#metadata-is-optional"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;You don&amp;rsquo;t need metadata to use pgmi.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The basic template works perfectly without any metadata. Files execute in lexicographic path order, and pgmi generates deterministic fallback identifiers from file paths.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;myproject/
├── deploy.sql # No metadata needed
├── migrations/
│ ├── 001_users.sql # No metadata needed
│ └── 002_orders.sql # No metadata needed
└── __test__/
 └── test_users.sql # No metadata needed&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This is often sufficient. Add metadata only when you need its specific capabilities.&lt;/p&gt;</description></item><item><title>Testing</title><link>https://vvka-141.github.io/pgmi/docs/testing/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/testing/</guid><description>&lt;h1 id="database-testing-with-pgmi"&gt;Database Testing with pgmi&lt;a class="anchor" href="#database-testing-with-pgmi"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;This guide teaches you how to test your PostgreSQL code using pgmi — from your first test to hierarchical fixtures. Every example is copy-paste ready.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="the-problem-pgmi-solves"&gt;The problem pgmi solves&lt;a class="anchor" href="#the-problem-pgmi-solves"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Testing database code is hard because &lt;strong&gt;changes persist&lt;/strong&gt;. If a test creates a table, that table exists for the next test. If a test inserts rows, those rows are visible to every test that follows. Tests become order-dependent, flaky, and impossible to run in isolation.&lt;/p&gt;</description></item><item><title>Security</title><link>https://vvka-141.github.io/pgmi/docs/security/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/security/</guid><description>&lt;h1 id="security-guide"&gt;Security Guide&lt;a class="anchor" href="#security-guide"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;pgmi handles sensitive parameters (passwords, API keys, tokens) as part of database deployments. This guide covers pgmi&amp;rsquo;s security model, known threat vectors, and recommended practices for CI/CD pipelines.&lt;/p&gt;
&lt;blockquote class='book-hint '&gt;
&lt;p&gt;&lt;strong&gt;API keys&lt;/strong&gt;: the advanced template ships a machine-to-machine API key subsystem (&lt;code&gt;membership.api_key&lt;/code&gt;, SHA-256-hashed, hash-safe compare, SECURITY DEFINER lifecycle). See &lt;a href="https://vvka-141.github.io/pgmi/docs/api-keys/"&gt;API keys&lt;/a&gt;
.&lt;/p&gt;
&lt;/blockquote&gt;&lt;h2 id="required-permissions"&gt;Required Permissions&lt;a class="anchor" href="#required-permissions"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Operation&lt;/th&gt;
					&lt;th&gt;Minimum Privilege&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;pgmi deploy&lt;/code&gt; (new database)&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;CREATEDB&lt;/code&gt; on the PostgreSQL cluster&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;pgmi deploy&lt;/code&gt; (existing database)&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;CREATE&lt;/code&gt; on &lt;code&gt;pg_temp&lt;/code&gt; schema (granted by default to all roles)&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;DDL in migrations&lt;/td&gt;
					&lt;td&gt;Depends on your SQL — typically schema owner or &lt;code&gt;CREATE&lt;/code&gt; on target schema&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Advanced template role setup&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;CREATEROLE&lt;/code&gt; + &lt;code&gt;CREATE EXTENSION&lt;/code&gt; (initial setup only — no superuser)&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;pgmi itself only needs to: connect, create temp tables (automatic for any role), set session variables, and execute your deploy.sql. The actual permissions depend on what your SQL does.&lt;/p&gt;</description></item><item><title>Production</title><link>https://vvka-141.github.io/pgmi/docs/production/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/production/</guid><description>&lt;h1 id="production-guide"&gt;Production Guide&lt;a class="anchor" href="#production-guide"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;This guide covers considerations for running pgmi in production environments: performance, rollback strategies, monitoring, and operational patterns.&lt;/p&gt;
&lt;h2 id="connection-requirements"&gt;Connection requirements&lt;a class="anchor" href="#connection-requirements"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;pgmi requires a &lt;strong&gt;direct PostgreSQL connection&lt;/strong&gt; or a connection pooler in &lt;strong&gt;session mode&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;pgmi uses session-scoped temporary tables (&lt;code&gt;pg_temp&lt;/code&gt;) that exist only for the lifetime of a single database connection. Connection poolers in transaction or statement mode reassign connections between operations, destroying the temporary tables mid-deployment.&lt;/p&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Pooler Mode&lt;/th&gt;
					&lt;th&gt;Compatible&lt;/th&gt;
					&lt;th&gt;Why&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;Session&lt;/td&gt;
					&lt;td&gt;Yes&lt;/td&gt;
					&lt;td&gt;Connection stays with one backend for the entire session&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Transaction&lt;/td&gt;
					&lt;td&gt;&lt;strong&gt;No&lt;/strong&gt;&lt;/td&gt;
					&lt;td&gt;Backend may change between transactions — &lt;code&gt;pg_temp&lt;/code&gt; state lost&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Statement&lt;/td&gt;
					&lt;td&gt;&lt;strong&gt;No&lt;/strong&gt;&lt;/td&gt;
					&lt;td&gt;Backend may change between statements — &lt;code&gt;pg_temp&lt;/code&gt; state lost&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;This applies to PgBouncer, Pgpool-II, AWS RDS Proxy, Azure PgBouncer, and any other connection pooler. Direct connections are always safe. If you use a pooler, either configure session mode for pgmi deployments or bypass the pooler with a direct connection string.&lt;/p&gt;</description></item><item><title>CI/CD</title><link>https://vvka-141.github.io/pgmi/docs/cicd/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/cicd/</guid><description>&lt;h1 id="cicd"&gt;CI/CD&lt;a class="anchor" href="#cicd"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Deploy pgmi projects from any CI system. The pattern is always the same: install a
&lt;strong&gt;pinned&lt;/strong&gt; pgmi binary, point it at a &lt;strong&gt;direct&lt;/strong&gt; database connection via secrets, and
run &lt;code&gt;pgmi deploy&lt;/code&gt; with a pinned API version.&lt;/p&gt;
&lt;h2 id="requirements"&gt;Requirements&lt;a class="anchor" href="#requirements"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A direct PostgreSQL connection&lt;/strong&gt; (or a session-mode pooler). Transaction-mode
poolers — PgBouncer in &lt;code&gt;transaction&lt;/code&gt; mode, AWS RDS Proxy, Azure&amp;rsquo;s built-in
PgBouncer — reassign connections between statements and destroy the session-scoped
temp tables pgmi relies on. See
&lt;a href="https://vvka-141.github.io/pgmi/docs/production/#connection-requirements"&gt;Connection Requirements&lt;/a&gt;
.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Secrets from your CI secret store&lt;/strong&gt;, never on the command line. See the
&lt;a href="https://vvka-141.github.io/pgmi/docs/security/"&gt;Security Guide&lt;/a&gt;
.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="github-actions"&gt;GitHub Actions&lt;a class="anchor" href="#github-actions"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;Deploy database&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;on&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;push&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;branches&lt;/span&gt;: [&lt;span style="color:#ae81ff"&gt;main]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;jobs&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;deploy&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;runs-on&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;ubuntu-latest&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;env&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;PGMI_VERSION&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;v0.11.0 &lt;/span&gt; &lt;span style="color:#75715e"&gt;# pin to a specific release tag&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;DB_NAME&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;myapp&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;steps&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;uses&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;actions/checkout@v4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;Install pgmi (pinned, checksum-verified)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;run&lt;/span&gt;: |&lt;span style="color:#e6db74"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; file=&amp;#34;pgmi_${PGMI_VERSION#v}_linux_amd64.tar.gz&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; base=&amp;#34;https://github.com/vvka-141/pgmi/releases/download/${PGMI_VERSION}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; curl -fsSLO &amp;#34;${base}/${file}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; curl -fsSLO &amp;#34;${base}/checksums.txt&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; sha256sum --ignore-missing -c checksums.txt
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; tar -xzf &amp;#34;${file}&amp;#34; pgmi
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; sudo install pgmi /usr/local/bin/pgmi
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; pgmi --version&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;Deploy&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;env&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;PGMI_CONNECTION_STRING&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;${{ secrets.DATABASE_URL }} &lt;/span&gt; &lt;span style="color:#75715e"&gt;# direct connection&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;run&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;pgmi deploy . -d &amp;#34;$DB_NAME&amp;#34; --compat 1 --force&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Why these choices:&lt;/p&gt;</description></item><item><title>MCP integration</title><link>https://vvka-141.github.io/pgmi/docs/mcp/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/mcp/</guid><description>&lt;h1 id="model-context-protocol-mcp-integration"&gt;Model Context Protocol (MCP) Integration&lt;a class="anchor" href="#model-context-protocol-mcp-integration"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;pgmi&amp;rsquo;s advanced template includes a complete MCP server implementation, enabling AI assistants (Claude Desktop, VS Code Copilot, etc.) to interact with your PostgreSQL database through tools, resources, and prompts.&lt;/p&gt;
&lt;h2 id="overview"&gt;Overview&lt;a class="anchor" href="#overview"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Model Context Protocol (MCP) is an open standard that allows AI applications to connect to external systems. pgmi implements MCP entirely in PostgreSQL, with a thin HTTP gateway for transport.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────────────┐
│ AI Client │────▶│ HTTP Gateway │────▶│ PostgreSQL │
│ (Claude, etc.) │ │ (Python/Go) │ │ │
│ │◀────│ │◀────│ api.mcp_handle_request() │
└─────────────────┘ └─────────────────┘ │ ├── tools (execute actions) │
 │ ├── resources (read data) │
 │ └── prompts (message templates)│
 └─────────────────────────────────┘&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="quick-start"&gt;Quick Start&lt;a class="anchor" href="#quick-start"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id="1-deploy-the-advanced-template"&gt;1. Deploy the Advanced Template&lt;a class="anchor" href="#1-deploy-the-advanced-template"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pgmi init --template advanced myproject
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd myproject
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pgmi deploy --connection &lt;span style="color:#e6db74"&gt;&amp;#34;postgresql://user:pass@localhost:5432/mydb&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="2-start-the-http-gateway"&gt;2. Start the HTTP Gateway&lt;a class="anchor" href="#2-start-the-http-gateway"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;pgmi init --template advanced&lt;/code&gt; command generates a &lt;code&gt;tools/&lt;/code&gt; directory with the Python gateway:&lt;/p&gt;</description></item><item><title>API keys</title><link>https://vvka-141.github.io/pgmi/docs/api-keys/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/api-keys/</guid><description>&lt;h1 id="api-key-authentication"&gt;API Key Authentication&lt;a class="anchor" href="#api-key-authentication"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Machine-to-machine authentication for agents, MCP clients, and CI pipelines. Ships with the advanced template in &lt;code&gt;membership/08-api-keys.sql&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="key-format"&gt;Key format&lt;a class="anchor" href="#key-format"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{prefix}_{key_id}_{secret}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;prefix&lt;/strong&gt; — short tenant-configurable label (default &lt;code&gt;pgmi&lt;/code&gt;), sourced from the &lt;code&gt;pgmi.api_key_prefix&lt;/code&gt; GUC. Set via &lt;code&gt;ALTER DATABASE mydb SET pgmi.api_key_prefix = 'myapp'&lt;/code&gt; or &lt;code&gt;--param api_key_prefix=myapp&lt;/code&gt; on deploy.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;key_id&lt;/strong&gt; — 8-char alphanumeric identifier stored unhashed for O(1) lookup. Never secret on its own.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;secret&lt;/strong&gt; — 32 bytes of random material encoded as URL-safe base64.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Only &lt;code&gt;SHA-256(full_key)&lt;/code&gt; is persisted. The raw key is returned exactly once, at creation, and never recoverable.&lt;/p&gt;</description></item><item><title>Session API</title><link>https://vvka-141.github.io/pgmi/docs/session-api/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/session-api/</guid><description>&lt;h1 id="pgmi-session-api-reference"&gt;pgmi Session API Reference&lt;a class="anchor" href="#pgmi-session-api-reference"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;blockquote class='book-hint '&gt;
&lt;p&gt;&lt;strong&gt;Core model:&lt;/strong&gt; pgmi doesn&amp;rsquo;t interpret your SQL — it loads your files into PostgreSQL session tables and hands control to &lt;code&gt;deploy.sql&lt;/code&gt;, which decides what to do with them.&lt;/p&gt;
&lt;/blockquote&gt;&lt;h2 id="how-pgmi-actually-works"&gt;How pgmi Actually Works&lt;a class="anchor" href="#how-pgmi-actually-works"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When you run &lt;code&gt;pgmi deploy ./myproject&lt;/code&gt;, here&amp;rsquo;s what happens:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;┌─────────────────────────────────────────────────────────────────────────┐
│ 1. CONNECT │
│ pgmi connects to PostgreSQL │
└────────────────────────────────────────────┬────────────────────────────┘
 │
 ▼
┌─────────────────────────────────────────────────────────────────────────┐
│ 2. PREPARE SESSION │
│ pgmi creates temporary tables and views (two-tier API): │
│ │
│ Internal tables: _pgmi_source, _pgmi_parameter, _pgmi_source_metadata│
│ _pgmi_test_source, _pgmi_test_directory │
│ Public views: pgmi_source_view, pgmi_parameter_view, pgmi_plan_view│
│ pgmi_source_metadata_view │
│ pgmi_test_source_view, pgmi_test_directory_view │
│ │
│ If --verbose: SET client_min_messages = &amp;#39;debug&amp;#39; (enables RAISE DEBUG)│
│ Functions: pgmi_test_plan(), pgmi_test_generate() │
└────────────────────────────────────────────┬────────────────────────────┘
 │
 ▼
┌─────────────────────────────────────────────────────────────────────────┐
│ 3. EXECUTE deploy.sql │
│ YOUR deploy.sql runs and directly executes files using: │
│ │
│ FOR v_file IN (SELECT * FROM pgmi_plan_view ORDER BY execution_order)│
│ LOOP │
│ EXECUTE v_file.content; │
│ END LOOP; │
│ │
│ Transaction boundaries, error handling, execution order—all yours. │
└─────────────────────────────────────────────────────────────────────────┘&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;The key insight:&lt;/strong&gt; deploy.sql is the deployment script. It queries &lt;code&gt;pgmi_plan_view&lt;/code&gt; and uses &lt;code&gt;EXECUTE&lt;/code&gt; to run files directly. You control the deployment logic — transactions, ordering, conditionals, error handling.&lt;/p&gt;</description></item><item><title>Trade-offs</title><link>https://vvka-141.github.io/pgmi/docs/tradeoffs/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vvka-141.github.io/pgmi/docs/tradeoffs/</guid><description>&lt;h1 id="honest-limitations"&gt;Honest Limitations&lt;a class="anchor" href="#honest-limitations"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;pgmi trades framework-managed complexity for SQL-level control. That trade has real costs. This page lists them honestly so you can decide if they apply to your team and project.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="plpgsql-expertise-required"&gt;PL/pgSQL expertise required&lt;a class="anchor" href="#plpgsql-expertise-required"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;pgmi&amp;rsquo;s &lt;code&gt;deploy.sql&lt;/code&gt; is a PL/pgSQL program, not configuration. Your team needs to be comfortable with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;FOR v_file IN (SELECT ...) LOOP ... END LOOP&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;EXECUTE v_file.content&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;BEGIN ... EXCEPTION WHEN OTHERS THEN ... END&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;current_setting('pgmi.key', true)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Honest test:&lt;/strong&gt; If your team would struggle to write a PL/pgSQL function that loops over a query result, calls &lt;code&gt;EXECUTE&lt;/code&gt; on each row, and handles exceptions — pgmi&amp;rsquo;s power is inaccessible. The basic template works out of the box, but customizing deployment logic requires PL/pgSQL fluency.&lt;/p&gt;</description></item></channel></rss>