PostgreSQL Schema Management Tools Compared: How to Choose the Right One (With AI Agents in Mind)
Flyway, Liquibase, Atlas, Bytebase, pgroll, dbmate and more—what each tool does best, which one fits your team, how to use them with managed PostgreSQL on AWS, Google Cloud or Azure, and a real decision we made for a client.
Introduction: Every Database Change Needs a Process
Every application that uses PostgreSQL eventually needs to change its database: a new table, an extra column, a better index. Done by hand, these changes cause trouble—a column exists in QA but not in Prod, an index was added directly on the server and nobody remembers why, or a "quick" change locks a busy table during peak hours.
Schema management tools solve this. They keep every change in version control, apply changes in the same order everywhere, and record what has run on each database. Some also check changes for dangerous patterns, control who can deploy to production, and now even let AI coding agents draft changes safely.
There are many tools, and they work in very different ways. This guide explains the main types, compares the most popular options, shows what changes when you use managed PostgreSQL on AWS, Google Cloud, Azure or DigitalOcean, and walks through a real decision we made for a client.
1. What Schema Management Means for PostgreSQL
A schema migration is a controlled change to your database structure. A migration tool stores those changes as code, applies the ones that have not run yet, and records each one in a history table inside the database.
PostgreSQL deserves extra care because some changes take locks that block reads or writes:
CREATE INDEXwithoutCONCURRENTLYblocks writes to the table until the index is built.- Changing a column's type can rewrite the whole table while holding a strong lock.
- Adding a foreign key or check constraint scans the table unless you add it as
NOT VALIDfirst and validate it later. - A migration waiting for a lock can block every query queued behind it. Setting a
lock_timeoutprevents a small change from causing a big outage.
The right tool—or the right checks around it—catches these problems before they reach production.
2. What to Look for in a Tool
Before comparing tools, decide what matters to your team. These are the questions we used:
| Question | Why it matters |
|---|---|
| Do we want to write plain SQL? | SQL is the most flexible way to use PostgreSQL features, and the easiest for people and AI agents to review |
| Does it support the PostgreSQL features we use? | Functions, triggers, row-level security, extensions (such as pgvector or PostGIS), partitions |
| Does it check changes for risk? | Catching locks, data loss and missing primary keys before deployment |
| How does a change move from Dev to Prod? | Order, approvals and who is allowed to deploy to production |
| Can it detect drift? | Finding changes made directly on a database outside the process |
| How does it handle rollback? | Down migrations, generated undo scripts, or roll-forward fixes |
| Does it fit our CI/CD and cloud? | Running from GitHub Actions, GitLab, Azure DevOps or Jenkins, and reaching private databases |
| Can AI agents use it safely? | Plain files, an MCP server, and permissions that keep agents away from production |
| What is the licence and cost? | Open source, source-available or commercial—and which features are in the free edition |
3. The Main Types of Tools
Most confusion disappears once you see that tools solve different problems. The key difference is who writes the SQL and who decides when it runs.
| Type | How it works | Examples | Best for |
|---|---|---|---|
| Versioned (imperative) | You write numbered migration files; the tool applies them in order and records what ran | Flyway, Liquibase, golang-migrate, dbmate, Sqitch, Graphile Migrate | Full control and a predictable history |
| Declarative (schema-as-code) | You describe the desired schema; the tool compares it with the database and generates the SQL | Atlas, pg-schema-diff | Less hand-written SQL and easy drift detection |
| Zero-downtime | Old and new schema versions run side by side while applications switch over | pgroll | Large tables and services that cannot pause |
| Governance platform | A control plane for reviews, environments, rollouts and history on top of migrations | Bytebase, Harness Database DevOps | Several environments, reviewers and compliance rules |
| Framework tools | Migrations generated from your application models | Prisma Migrate, Drizzle Kit, Alembic, Django, Rails, EF Core | One application that owns its database |
| Linters | Check migration SQL for risky PostgreSQL patterns | Squawk | Any team, alongside any tool |
4. The Tools Compared
Here are the tools worth knowing for PostgreSQL. Licences and editions were checked on 3 December 2026.
| Tool | Licence / edition | Approach | Strengths | Watch out for |
|---|---|---|---|---|
| Flyway | Community: Apache 2.0; Teams/Enterprise: commercial | Versioned SQL or Java | Simple, very popular, strong Java/Spring support | Undo migrations and the official MCP server are paid |
| Liquibase | Community: Functional Source License (FSL); Secure: commercial | Versioned (SQL, XML, YAML or JSON) | Mature, many databases, built-in rollback | FSL is source-available, not OSI open source; AI features are in the paid edition |
| Atlas | Community build: Apache 2.0; standard CLI: free tier + Pro | Declarative (HCL or SQL) or versioned | Computes diffs, strong PostgreSQL support, drift detection | Migration linting and many features need Atlas Pro |
| Bytebase | Community: free (mostly MIT); Enterprise: commercial | Versioned SQL with web UI and GitOps | SQL review, environments, rollouts, built-in MCP server | Approval workflow, audit log and custom roles need Enterprise |
| pgroll | Apache 2.0 | Zero-downtime, JSON migrations | Expand/contract without locking applications out | PostgreSQL 14+ only; a new way of thinking |
| golang-migrate | MIT | Versioned up/down SQL files | Tiny, simple, widely used | No safety checks |
| dbmate | MIT | Versioned SQL (up and down in one file) | Single binary, works with any language | No safety checks |
| Sqitch | MIT | Versioned SQL with dependencies | Changes declare dependencies, not just order | Steeper learning curve |
| Graphile Migrate | MIT | Roll-forward SQL, PostgreSQL-only | Fast local iteration with a "current" file | Roll-forward only, by design |
| pg-schema-diff (Stripe) | MIT | Declarative diff for PostgreSQL | Generates low-lock SQL such as concurrent indexes | Early stage; limited type support |
| Harness Database DevOps | Commercial | CI/CD pipelines over migration engines | Fits teams already on Harness | Paid platform |
| Squawk | Apache 2.0 / MIT | Linter (not a runner) | Free checks for locking and risky changes | Use together with a migration tool |
Which tool fits which team?
| If your team… | Consider | Why |
|---|---|---|
| Is small and wants plain SQL with minimal tooling | dbmate or golang-migrate | Easy to learn and run in any CI |
| Builds Java or Spring services | Flyway or Liquibase | Framework integration and large communities |
| Has one application that owns the database | Your framework's tool | Migrations stay next to your models |
| Wants to describe the schema and let a tool generate SQL | Atlas | Declarative diffs and drift detection |
| Changes large, busy tables often | pgroll | Avoids long locks; old and new app versions run together |
| Has several environments, reviewers and compliance needs | Bytebase (or Harness if you already use it) | Reviews, rollout control and history in one place |
| Uses AI coding agents heavily | Plain SQL tools plus a governance layer with an MCP server | Agents work best with SQL and need limited permissions |
5. Managed PostgreSQL on AWS, Google Cloud, Azure and DigitalOcean
Every tool in this guide works with managed PostgreSQL. The tool connects to your database like any other client. What changes is the platform around it.
| Platform | Managed PostgreSQL | Private network | Admin role (not a true superuser) | Where to keep credentials |
|---|---|---|---|---|
| AWS | Amazon RDS for PostgreSQL, Aurora PostgreSQL | VPC + security groups | rds_superuser | AWS Secrets Manager |
| Google Cloud | Cloud SQL for PostgreSQL, AlloyDB | VPC with private IP | cloudsqlsuperuser | Secret Manager |
| Azure | Azure Database for PostgreSQL – Flexible Server | VNet integration or private endpoint | azure_pg_admin | Azure Key Vault |
| DigitalOcean | Managed Databases for PostgreSQL (or self-hosted on Droplets) | VPC + trusted sources / cloud firewall | doadmin | Your CI/CD secret store |
| Self-hosted | PostgreSQL on your own VMs or Kubernetes | Your own network | Real superuser available | Vault or your CI/CD secret store |
What to watch on managed services
- No true superuser. Managed services give you a powerful admin role, but some statements that need superuser rights—such as certain extension or replication settings—are not allowed. Test migrations against the same service you use in production, not just a local Docker database.
- Extensions are allowlisted. Each provider supports its own list of extensions and versions. Check before you write a migration that depends on pgvector, PostGIS or anything less common.
- Reach private databases from CI. A cloud-hosted CI runner usually cannot reach a database on a private network. Use a self-hosted runner inside the network, a bastion or tunnel, or a control plane such as Bytebase deployed next to the databases.
- Use cloud identity where you can. Amazon RDS, Cloud SQL and Azure support signing in with cloud identities (IAM or Microsoft Entra ID) instead of long-lived passwords. Check whether your migration tool can use them.
- Use separate roles. Give the migration tool a role that can change the schema, and give applications a role that cannot.
- Take advantage of copies. Snapshots, clones, branches (on services such as Neon) or a restored backup are ideal for rehearsing a risky migration on real-sized data.
6. Using AI Coding Agents With Schema Changes
AI coding agents such as Claude Code, OpenAI Codex and Cursor are good at writing migrations: they read the existing schema, follow your conventions and remember PostgreSQL details such as CONCURRENTLY. But a migration is one of the riskiest changes an agent can make. These principles keep it safe with any tool:
- Prefer plain SQL migration files. Agents and reviewers can read and check them easily.
- Never give an agent production credentials. Let it read schemas in Dev and propose changes.
- Run automatic checks on every change—a linter such as Squawk or the built-in review of your tool.
- Keep a person in charge of QA and Prod. The agent proposes; a named person approves and deploys.
- Use a governed connection if you can. An MCP server that works through your migration tool's permissions is safer than giving an agent a database connection string.
| Tool | AI agent support (December 2026) |
|---|---|
| Bytebase | Built-in MCP server in the free Community edition |
| Flyway | Official MCP server, Flyway Enterprise only |
| Atlas | Agent skills for Claude Code and other agents; some commands need an Atlas login |
| Liquibase | AI features in the paid Liquibase Secure edition |
| SQL-file tools (dbmate, golang-migrate, Sqitch) | No special integration needed—agents write plain SQL files that you review in pull requests |
7. A Worked Example: How We Chose a Tool for a Client
Here is how we used this framework for a real client. Their team already used a versioned migration tool and wanted a setup that fit how they now work. Your requirements will differ, but the process is the same.
The requirements
- PostgreSQL only, self-hosted on DigitalOcean Droplets.
- Three environments—Dev, QA and Prod—with the same change promoted in order.
- Open source and self-hosted first: credentials and schema history stay in their own infrastructure.
- Guardrails: automatic checks for risky PostgreSQL changes before anything reaches Prod.
- Human control over QA and Prod deployments.
- AI coding agents: Claude Code and Codex should be able to inspect schemas and draft migrations—without direct access to production.
How the shortlist scored
| Requirement | Flyway | Liquibase | Atlas | Bytebase |
|---|---|---|---|---|
| Plain SQL migrations | Yes | Yes (formatted SQL) | Yes | Yes |
| Self-hosted | Yes | Yes | Yes (CLI) | Yes |
| Open-source licence for what we need | Community: yes | FSL (source-available) | Community build: yes | Community: mostly MIT |
| PostgreSQL safety checks | Paid edition | Paid edition | Atlas Pro | Free (SQL review) |
| Dev → QA → Prod rollout control | Build in CI | Build in CI | CI or Atlas Cloud | Built in |
| Web UI for reviewers | Paid edition | Paid edition | Atlas Cloud | Built in |
| Official MCP server for AI agents | Enterprise only | Not found | Agent skills | Built in, free |
The decision: Bytebase, with Atlas as runner-up
We chose Bytebase Community, self-hosted next to the databases. It covered the most requirements in its free edition:
- Self-hosted control plane: a single Docker container; credentials and history stay on the client's servers.
- Environments built in: Dev, QA and Prod are first-class, and the same SQL moves through them in order with a visual diff.
- Free PostgreSQL guardrails: SQL review rules flag non-concurrent index builds, tables without a primary key, and backward-incompatible changes such as dropped columns.
- Built-in MCP server: AI agents work through Bytebase's permissions instead of holding database passwords.
Why Atlas came second: excellent PostgreSQL support and a powerful declarative workflow, but linting and many features need Atlas Pro, and a central review UI needs Atlas Cloud. For a CLI-first team happy to pay per developer, it would be a strong choice.
Why not Flyway or Liquibase: both are solid runners, but the safety checks, reviewer UI and AI integration we wanted are in their paid editions. Liquibase's FSL licence also did not meet the client's open-source preference.
8. A Safe Architecture That Works on Any Cloud
Whichever tool you pick, the safest setup has one control point inside your private network. Databases are never exposed to the internet, and people, CI pipelines and AI agents make changes through that control point.
| Building block | AWS | Google Cloud | Azure | DigitalOcean (our example) |
|---|---|---|---|---|
| Private network | VPC | VPC | VNet | VPC |
| Block public database access | Security groups | Private IP only / firewall rules | Private access / NSG | Cloud firewall / trusted sources |
| Host for the control point | EC2, ECS or EKS | Compute Engine, Cloud Run or GKE | VM, Container Apps or AKS | Droplet |
| Secure access for people | Client VPN, SSM or a tunnel | IAP or a VPN | Bastion or a VPN | Tailscale or an SSH tunnel |
In our example, a small Droplet (2 vCPU / 4 GB RAM) runs Bytebase in the same DigitalOcean VPC as the three PostgreSQL servers, and engineers reach it through Tailscale. For more on Droplets and VPCs, see our DigitalOcean hosting guide.
9. Example Setup: Bytebase in Five Steps
These steps are the same on any cloud. Only the network and host from the table above change.
Step 1: Run Bytebase with Docker Compose
On a small VM or container host inside your private network, create a compose file. Pin a version tag instead of latest, so upgrades happen when you choose:
docker-compose.yml
services:
bytebase:
image: bytebase/bytebase:<version> # pin a release from Docker Hub
container_name: bytebase
init: true
restart: unless-stopped
ports:
- "127.0.0.1:8080:8080" # local only; reach it via VPN or tunnel
volumes:
- /var/opt/bytebase:/var/opt/bytebaseStart Bytebase
sudo mkdir -p /var/opt/bytebase
sudo docker compose up -dFor production, store Bytebase's own metadata in an external, backed-up PostgreSQL database—a managed database works well. Follow the "external PostgreSQL" section of the Bytebase self-hosting documentation for the current setting.
Step 2: Add environments and databases
- Open Bytebase through your tunnel or VPN and create the admin account.
- Under Environments, create Dev, QA and Prod.
- Under Instances, add each PostgreSQL server or managed database using its private address. Use a dedicated database role for Bytebase with only the privileges it needs.
- Create a project and add the databases to it.
- Set the external URL in workspace settings to the address people use to reach Bytebase. The MCP server needs it.
Step 3: Turn on SQL review
Attach SQL review policies to each environment—warnings in Dev so developers can move quickly, errors for important rules in QA and Prod. Rules worth enabling for PostgreSQL:
- Create indexes concurrently.
- Require a primary key on every table.
- Flag backward-incompatible changes such as dropping or renaming tables and columns.
- Naming conventions for tables, indexes and constraints.
Step 4: Decide who can deploy where
| Environment | Checks | Who rolls out | AI agent can… |
|---|---|---|---|
| Dev | Warnings | Automatic when checks pass | Propose changes and apply them to Dev |
| QA | Errors block the change | Developer or QA lead | Propose changes; a person rolls out |
| Prod | Errors block the change | DBA or tech lead, with a backup | Read the schema and propose only |
Step 5: Connect Claude Code through Bytebase MCP
Bytebase has an MCP server built in at /mcp on your Bytebase URL. The workspace's MCP access policy starts as read-only—keep it that way until you are comfortable. Add it to Claude Code:
Terminal
claude mcp add --transport http bytebase https://bytebase.internal.example.com/mcpThen run /mcp in Claude Code, select bytebase, choose Authenticate and approve access in the browser. Claude acts with that Bytebase user's permissions, so use a developer-level project role—not Workspace Admin or Workspace DBA.
10. The Day-to-Day Workflow
Example prompt for Claude Code
Using Bytebase, inspect the invoices table in the Dev database of our project.
Draft a migration that adds a status column (text, not null, default 'draft') and an index on customer_id for rows where status = 'open'.
Use CREATE INDEX CONCURRENTLY, run SQL review, and show me the SQL and the review results before creating any change.A good result looks like this:
migrations/20261203_add_invoice_status.sql
SET lock_timeout = '5s';
ALTER TABLE invoices
ADD COLUMN status text NOT NULL DEFAULT 'draft';
-- Must run outside a transaction block
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_invoices_open_customer
ON invoices (customer_id)
WHERE status = 'open';Since PostgreSQL 11, adding a column with a constant default does not rewrite the table, so the first statement is fast even on large tables. Changing a column's type is different—it can rewrite the whole table and lock it while it does.
11. Add a Free Safety Net: Squawk
Whatever tool you choose, a linter catches many PostgreSQL mistakes before review. Squawk is free and flags patterns such as non-concurrent index builds, constraints added without NOT VALID, and dropped columns. Run it locally or in CI:
Lint migrations locally or in CI
npm install -g squawk-cli
squawk migrations/*.sqlAtlas offers similar checks with atlas migrate lint, which requires an Atlas Pro login, and Bytebase includes them in its SQL review.
12. Switching Tools Without Breaking Anything
If you already use a migration tool—Flyway, Liquibase or anything else—switch gradually:
- Freeze a baseline. Take a schema-only dump (
pg_dump --schema-only) of each environment and confirm they match. - Start the new tool from that baseline. Mark it as already applied so old changes are not run again.
- Keep the old history tables (for example
flyway_schema_historyordatabasechangelog) for reference, then archive them. - Rehearse a full cycle from Dev to QA to Prod on a copy before the first real change.
- Write down the new process: who drafts, who reviews, who deploys and how to roll back.
13. Final Thoughts
PostgreSQL schema management has more good options than ever. Plain SQL runners keep things simple, declarative tools write the SQL for you, pgroll handles zero-downtime changes, and governance platforms bring reviews and environments together—now with AI agents in the loop.
Start from your team's needs, not from a feature list: how you write changes, how they reach production, where your databases run, and what your licence policy allows. Whatever you choose, add automatic checks for locking mistakes and keep a person in charge of production.
Which tool does your team use for PostgreSQL schema changes, and why? Share your experience with the TechTalks.community readers.
Frequently Asked Questions
1. What is the best PostgreSQL migration tool?
It depends on your team. dbmate or golang-migrate suit small teams that want plain SQL; Flyway and Liquibase suit Java teams; Atlas suits schema-as-code; pgroll suits zero-downtime changes; and Bytebase suits teams that need environments, reviews and AI-agent access in one place.
2. Do these tools work with Amazon RDS, Cloud SQL and Azure Database for PostgreSQL?
Yes. They connect like any PostgreSQL client. Plan for private network access from CI, the managed admin role (not a true superuser), and the provider's supported extensions.
3. Is Flyway or Liquibase better for PostgreSQL?
Both work well. Flyway is simpler and SQL-first; Liquibase offers more formats and built-in rollback. Compare the editions you would actually use, because many advanced features are paid.
4. Is Bytebase really free?
Bytebase Community is free for up to 20 users and 10 database instances and includes SQL review, rollout policies and the MCP server. Formal approval workflows, audit logs, custom roles, SSO and data masking require Enterprise.
5. Should AI agents be allowed to change production databases?
Not directly. Let agents read schemas and propose migrations, run automatic checks, and keep QA and Prod deployments with named people.
6. What is the difference between declarative and versioned migrations?
With versioned migrations you write each change as a file and the tool applies them in order. With declarative migrations you describe the final schema and the tool calculates the changes. Declarative tools save effort, but you should still review the generated SQL.
7. Do I need pgroll?
Only if you change large, busy tables and cannot afford locks or downtime. For most applications, careful SQL—concurrent indexes, NOT VALID constraints, a lock timeout and small batches—is enough.
Official Resources
- Flyway: https://www.red-gate.com/products/flyway/
- Liquibase: https://www.liquibase.com
- Atlas: https://atlasgo.io
- Bytebase: https://www.bytebase.com
- Bytebase MCP setup: https://docs.bytebase.com/integrations/mcp/setup
- Bytebase self-hosting with Docker: https://docs.bytebase.com/get-started/self-host/deploy-with-docker
- pgroll: https://github.com/xataio/pgroll
- golang-migrate: https://github.com/golang-migrate/migrate
- dbmate: https://github.com/amacneil/dbmate
- Sqitch: https://sqitch.org
- Graphile Migrate: https://github.com/graphile/migrate
- pg-schema-diff: https://github.com/stripe/pg-schema-diff
- Squawk: https://github.com/sbdchd/squawk
- PostgreSQL CREATE INDEX (CONCURRENTLY): https://www.postgresql.org/docs/current/sql-createindex.html
- PostgreSQL ALTER TABLE (locks and NOT VALID): https://www.postgresql.org/docs/current/sql-altertable.html
Licences, editions and features change often. This comparison was checked on 3 December 2026—confirm the details on each official page before you decide.