DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to gate schema migrations in CI with a Postgres lint with Pgbot

Fail a pull request when a schema change adds a critical finding, without a live production database.

Short answer: Create a disposable Postgres database for the CI job and give the job a read-only role connection string through a CI secret; then run pgbot lint to check the schema with no writes to the database; run pgbot inspect --profile=schema --fail-on=critical to make the exit code the CI gate. All steps.

Who it is forA platform or DevOps engineer who wants database checks on every migration pull request.

The problemSchema problems often reach production because nothing checks the migration before merge.

The outcomeA CI job that exits non-zero on critical schema findings and can emit SARIF for the GitHub Security tab.

What you need first

  • A PostgreSQL server version 14 to 18 that you can reach over the network
  • A login role with the pg_monitor role and no write grants (pgbot init generates the setup SQL)
  • The pgbot binary, installed with the curl install script or npx @pgbot/cli
  • Optional: pg_stat_statements for the queries section, and hypopg on PostgreSQL 16+ for advise

Steps

  1. Create a disposable Postgres database for the CI job and give the job a read-only role connection string through a CI secret.
  2. Run pgbot lint to check the schema with no writes to the database. (inferred, check the README)
  3. Run pgbot inspect --profile=schema --fail-on=critical to make the exit code the CI gate. (inferred, check the README)
  4. Add --format=sarif to the inspect command to produce output for the GitHub Security tab.
  5. Read the exit codes in CI: 0 clean, 1 warn, 2 critical, 3 connection or execution failure, 64 usage error.

Prompt for your agent

Use the pgbot tool from the pgrundev/pgbot repository in CI by running `pgbot inspect --profile=schema --fail-on=critical --format=sarif` against <ci-database-url>. Report the exit code and the number of findings in the SARIF output. Verify that exit code 3 is reported as a connection failure rather than as a finding.

Caveat. The schema profile only runs catalog-derived findings, so it does not replace checks that need live workload statistics.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for pgrundev/pgbot and "Gate schema migrations in CI with a Postgres lint"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer