pg-migration-verify
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| DATABASE_URL | No | Database URL used when PGMV_DATABASE_URL is unset, so the app's own variable works without a second copy. | |
| PGMV_PROJECT_DIR | No | Directory that relative paths, including PGMV_MIGRATIONS_DIR and the dir tool argument, are resolved against. | the server's working directory |
| PGMV_DATABASE_URL | No | A postgres:// or postgresql:// database URL, ideally for the read-only role. Takes precedence over DATABASE_URL. | |
| PGMV_DEFAULT_SCHEMA | No | Schema for unqualified names in migrations. | public |
| PGMV_MIGRATIONS_DIR | No | Migrations directory, relative to the project directory. May lie outside it. | supabase/migrations |
| PGMV_STATEMENT_TIMEOUT_MS | No | Per-statement timeout inside each read-only transaction. Must be a whole number from 1 to 2147483647, or startup fails. | 15000 |
| PGMV_ALLOW_OUTSIDE_PROJECT | No | Set to 1 to let the dir tool argument point outside the project directory and the migrations directory. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Checks whether Postgres/Supabase migrations were really applied, by comparing what each migration file should create, alter or drop with the live pg_catalog. The history table (supabase_migrations.schema_migrations) is often out of sync when migrations are pasted into the SQL editor, so verify objects instead of trusting it. Start with verify_all, or verify_migration for one file; diff_history compares files with the recorded history. All tools are read-only.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| list_repo_migrationsA | List the migration files in the repository (Supabase layout _.sql), in apply order (by file name, as the Supabase CLI applies them), with the sha256 of each file. Also reports .sql files the Supabase CLI would skip because of their name and versions used by more than one file. Use it to see which migrations exist or to find the exact file name for the other tools. Needs no database. Read-only: it reads migration files and pg_catalog inside a READ ONLY transaction, and never runs migration SQL or writes anything. |
| list_recorded_migrationsA | Show which migration versions the Supabase CLI recorded as applied in supabase_migrations.schema_migrations. A missing or unreadable table is reported in the result (history.status 'missing' or 'not_readable', with the grants needed), not as an error. This list is bookkeeping, not proof: migrations pasted into the SQL editor are never recorded, and a recorded one may be incomplete. Use verify_migration or verify_all to see whether objects exist. Read-only: it reads migration files and pg_catalog inside a READ ONLY transaction, and never runs migration SQL or writes anything. Needs a database URL (PGMV_DATABASE_URL or DATABASE_URL); without one it returns an error saying how to configure it. |
| diff_historyA | Compare the repository migration files with the recorded history table by version: only in repo (not recorded: pending, or applied by hand without recording), only in database (recorded, but no file has that version: deleted, renamed or from another branch) and in both (a different name is flagged). Compares bookkeeping only, not database objects: follow up with verify_migration for versions only in the repo. Read-only: it reads migration files and pg_catalog inside a READ ONLY transaction, and never runs migration SQL or writes anything. Needs a database URL (PGMV_DATABASE_URL or DATABASE_URL); without one it returns an error saying how to configure it. |
| expected_objectsA | Parse one migration with the real Postgres parser and list what it should leave in the database: schemas, tables, columns (type, nullability), indexes, constraints, functions, triggers, row level security, policies, types and enum values, each with its line, plus statements that cannot be checked (UNVERIFIABLE) or have no lasting effect (ignored, e.g. BEGIN or SET). Never connects to a database. Use it to review a migration before applying it, or to understand a verify_migration result. Read-only: it reads migration files and pg_catalog inside a READ ONLY transaction, and never runs migration SQL or writes anything. |
| verify_migrationA | Check whether one migration was really applied by comparing every object it should create, alter or drop with the live Postgres catalog, independently of the history table. Use it after applying a migration (e.g. by pasting it into the Supabase SQL editor) or whenever it is unclear whether a migration ran. Reports MATCH n/n or MISMATCH n/n with every problem object and the line it comes from, and whether the version is recorded in supabase_migrations.schema_migrations. Meaning of the output: MATCH = every object the migration should leave behind exists as written. MISMATCH = at least one object is MISSING (not found), DIFFERENT (found with other attributes, e.g. type or nullability) or UNEXPECTED (dropped or renamed by the migration but still there). MATCH* = a MATCH that does not show the file ran (every check would also hold without it), so "NOT recorded" there does not mean applied by hand. NOTHING TO VERIFY = no statement yields a catalog check. SUPERSEDED = a later migration drops or rebuilds the object or what it depends on (or IF NOT EXISTS skipped the statement), so it cannot be checked against this file; objects renamed later are checked under their new name. UNVERIFIABLE = a statement that cannot be checked against the catalog (DO blocks, GRANTs, data changes); review it by hand. Read-only: it reads migration files and pg_catalog inside a READ ONLY transaction, and never runs migration SQL or writes anything. Needs a database URL (PGMV_DATABASE_URL or DATABASE_URL); without one it returns an error saying how to configure it. |
| verify_allA | Check every repository migration against the live Postgres catalog. Returns a summary table (per migration: verdict, matched/checked, superseded, unverifiable, recorded in history) and the full report of each MISMATCH. The totals call out migrations applied but not recorded in history and migrations recorded but not fully applied. Use it for the whole picture or before a deploy; use verify_migration for one file. Meaning of the output: MATCH = every object the migration should leave behind exists as written. MISMATCH = at least one object is MISSING (not found), DIFFERENT (found with other attributes, e.g. type or nullability) or UNEXPECTED (dropped or renamed by the migration but still there). MATCH* = a MATCH that does not show the file ran (every check would also hold without it), so "NOT recorded" there does not mean applied by hand. NOTHING TO VERIFY = no statement yields a catalog check. SUPERSEDED = a later migration drops or rebuilds the object or what it depends on (or IF NOT EXISTS skipped the statement), so it cannot be checked against this file; objects renamed later are checked under their new name. UNVERIFIABLE = a statement that cannot be checked against the catalog (DO blocks, GRANTs, data changes); review it by hand. Read-only: it reads migration files and pg_catalog inside a READ ONLY transaction, and never runs migration SQL or writes anything. Needs a database URL (PGMV_DATABASE_URL or DATABASE_URL); without one it returns an error saying how to configure it. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 6 tools
Each tool has a distinct scope: verify_migration (one file) vs verify_all (whole repo), list_repo_migrations (files on disk) vs list_recorded_migrations (history table) vs diff_history (bookkeeping comparison), and expected_objects (parse-only, no DB). The descriptions explicitly cross-reference each other ("use verify_migration for one file", "follow up with verify_migration"), leaving little room for misselection.
Names are all snake_case and mostly verb_noun (verify_all, verify_migration, list_repo_migrations, list_recorded_migrations, diff_history). The one deviation is expected_objects, a noun phrase rather than a verb-first name, but it reads clearly and stays in the same style.
Six tools is well-scoped for a migration verification server, with a natural pairing of list/diff/parse/verify operations. Each tool covers a distinct layer (files, history, parsing, live catalog check) and none feels redundant.
The lifecycle is well covered: list repo files, list recorded history, diff the two, preview expected objects, verify one migration, verify all. Minor gaps exist, such as no direct tool to inspect raw live catalog objects (e.g. describe a table) or to verify an ad-hoc SQL snippet not present in the repo, but agents can work around these via expected_objects and the verify tools.