{
 "schema_version": 1,
 "generated": "2026-10-20",
 "id": "pgrundev-pgbot--gate-schema-migrations-in-ci",
 "repo": "pgrundev/pgbot",
 "repo_url": "https://github.com/pgrundev/pgbot",
 "repo_slug": "pgrundev-pgbot",
 "title": "Gate schema migrations in CI with a Postgres lint",
 "page_title": "How to gate schema migrations in CI with a Postgres lint with Pgbot",
 "summary": "Fail a pull request when a schema change adds a critical finding, without a live production database.",
 "who": "A platform or DevOps engineer who wants database checks on every migration pull request.",
 "problem": "Schema problems often reach production because nothing checks the migration before merge.",
 "outcome": "A CI job that exits non-zero on critical schema findings and can emit SARIF for the GitHub Security tab.",
 "steps": [
  "Create a disposable Postgres database for the CI job and give the job a read-only role connection string through a CI secret.",
  "Run `pgbot lint` to check the schema with no writes to the database. (inferred, check the README)",
  "Run `pgbot inspect --profile=schema --fail-on=critical` to make the exit code the CI gate. (inferred, check the README)",
  "Add `--format=sarif` to the inspect command to produce output for the GitHub Security tab.",
  "Read the exit codes in CI: 0 clean, 1 warn, 2 critical, 3 connection or execution failure, 64 usage error."
 ],
 "agent_prompt": "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.",
 "agents": [
  "any"
 ],
 "difficulty": "Advanced",
 "time": "1 hour",
 "basis": "readme",
 "caveat": "The schema profile only runs catalog-derived findings, so it does not replace checks that need live workload statistics.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "go",
 "requirements": [
  "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"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.7,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/pgrundev-pgbot/gate-schema-migrations-in-ci/",
 "md": "https://dedupedai.com/use-cases/pgrundev-pgbot/gate-schema-migrations-in-ci/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/pgrundev-pgbot--gate-schema-migrations-in-ci.json",
 "api_version": "v1"
}
