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.

By · · 18 min read · Databases

PostgreSQL schema management tools compared, with changes flowing from Dev to QA to Prod on any cloud

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 INDEX without CONCURRENTLY blocks 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 VALID first and validate it later.
  • A migration waiting for a lock can block every query queued behind it. Setting a lock_timeout prevents 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:

QuestionWhy 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.

Versioned runners: Liquibase, Flyway, golang-migrate, dbmate, Sqitch, Graphile Migrate. Declarative: Atlas, pg-schema-diff. Zero-downtime: pgroll. Governance platforms: Bytebase, Harness DB DevOps. Framework tools: Prisma Migrate, Drizzle Kit, Alembic, Django. Safety linter for any tool: Squawk.
Figure 1: Versioned runners apply files you write; declarative tools compute the SQL; governance platforms control who runs what, where.
TypeHow it worksExamplesBest for
Versioned (imperative)You write numbered migration files; the tool applies them in order and records what ranFlyway, Liquibase, golang-migrate, dbmate, Sqitch, Graphile MigrateFull control and a predictable history
Declarative (schema-as-code)You describe the desired schema; the tool compares it with the database and generates the SQLAtlas, pg-schema-diffLess hand-written SQL and easy drift detection
Zero-downtimeOld and new schema versions run side by side while applications switch overpgrollLarge tables and services that cannot pause
Governance platformA control plane for reviews, environments, rollouts and history on top of migrationsBytebase, Harness Database DevOpsSeveral environments, reviewers and compliance rules
Framework toolsMigrations generated from your application modelsPrisma Migrate, Drizzle Kit, Alembic, Django, Rails, EF CoreOne application that owns its database
LintersCheck migration SQL for risky PostgreSQL patternsSquawkAny 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.

ToolLicence / editionApproachStrengthsWatch out for
FlywayCommunity: Apache 2.0; Teams/Enterprise: commercialVersioned SQL or JavaSimple, very popular, strong Java/Spring supportUndo migrations and the official MCP server are paid
LiquibaseCommunity: Functional Source License (FSL); Secure: commercialVersioned (SQL, XML, YAML or JSON)Mature, many databases, built-in rollbackFSL is source-available, not OSI open source; AI features are in the paid edition
AtlasCommunity build: Apache 2.0; standard CLI: free tier + ProDeclarative (HCL or SQL) or versionedComputes diffs, strong PostgreSQL support, drift detectionMigration linting and many features need Atlas Pro
BytebaseCommunity: free (mostly MIT); Enterprise: commercialVersioned SQL with web UI and GitOpsSQL review, environments, rollouts, built-in MCP serverApproval workflow, audit log and custom roles need Enterprise
pgrollApache 2.0Zero-downtime, JSON migrationsExpand/contract without locking applications outPostgreSQL 14+ only; a new way of thinking
golang-migrateMITVersioned up/down SQL filesTiny, simple, widely usedNo safety checks
dbmateMITVersioned SQL (up and down in one file)Single binary, works with any languageNo safety checks
SqitchMITVersioned SQL with dependenciesChanges declare dependencies, not just orderSteeper learning curve
Graphile MigrateMITRoll-forward SQL, PostgreSQL-onlyFast local iteration with a "current" fileRoll-forward only, by design
pg-schema-diff (Stripe)MITDeclarative diff for PostgreSQLGenerates low-lock SQL such as concurrent indexesEarly stage; limited type support
Harness Database DevOpsCommercialCI/CD pipelines over migration enginesFits teams already on HarnessPaid platform
SquawkApache 2.0 / MITLinter (not a runner)Free checks for locking and risky changesUse together with a migration tool

Which tool fits which team?

If your team…ConsiderWhy
Is small and wants plain SQL with minimal toolingdbmate or golang-migrateEasy to learn and run in any CI
Builds Java or Spring servicesFlyway or LiquibaseFramework integration and large communities
Has one application that owns the databaseYour framework's toolMigrations stay next to your models
Wants to describe the schema and let a tool generate SQLAtlasDeclarative diffs and drift detection
Changes large, busy tables oftenpgrollAvoids long locks; old and new app versions run together
Has several environments, reviewers and compliance needsBytebase (or Harness if you already use it)Reviews, rollout control and history in one place
Uses AI coding agents heavilyPlain SQL tools plus a governance layer with an MCP serverAgents 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.

PlatformManaged PostgreSQLPrivate networkAdmin role (not a true superuser)Where to keep credentials
AWSAmazon RDS for PostgreSQL, Aurora PostgreSQLVPC + security groupsrds_superuserAWS Secrets Manager
Google CloudCloud SQL for PostgreSQL, AlloyDBVPC with private IPcloudsqlsuperuserSecret Manager
AzureAzure Database for PostgreSQL – Flexible ServerVNet integration or private endpointazure_pg_adminAzure Key Vault
DigitalOceanManaged Databases for PostgreSQL (or self-hosted on Droplets)VPC + trusted sources / cloud firewalldoadminYour CI/CD secret store
Self-hostedPostgreSQL on your own VMs or KubernetesYour own networkReal superuser availableVault 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:

  1. Prefer plain SQL migration files. Agents and reviewers can read and check them easily.
  2. Never give an agent production credentials. Let it read schemas in Dev and propose changes.
  3. Run automatic checks on every change—a linter such as Squawk or the built-in review of your tool.
  4. Keep a person in charge of QA and Prod. The agent proposes; a named person approves and deploys.
  5. 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.
ToolAI agent support (December 2026)
BytebaseBuilt-in MCP server in the free Community edition
FlywayOfficial MCP server, Flyway Enterprise only
AtlasAgent skills for Claude Code and other agents; some commands need an Atlas login
LiquibaseAI 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

  1. PostgreSQL only, self-hosted on DigitalOcean Droplets.
  2. Three environments—Dev, QA and Prod—with the same change promoted in order.
  3. Open source and self-hosted first: credentials and schema history stay in their own infrastructure.
  4. Guardrails: automatic checks for risky PostgreSQL changes before anything reaches Prod.
  5. Human control over QA and Prod deployments.
  6. 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

RequirementFlywayLiquibaseAtlasBytebase
Plain SQL migrationsYesYes (formatted SQL)YesYes
Self-hostedYesYesYes (CLI)Yes
Open-source licence for what we needCommunity: yesFSL (source-available)Community build: yesCommunity: mostly MIT
PostgreSQL safety checksPaid editionPaid editionAtlas ProFree (SQL review)
Dev → QA → Prod rollout controlBuild in CIBuild in CICI or Atlas CloudBuilt in
Web UI for reviewersPaid editionPaid editionAtlas CloudBuilt in
Official MCP server for AI agentsEnterprise onlyNot foundAgent skillsBuilt 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.

Engineers, a CI pipeline and Claude Code reach a migration control point through a VPN, SSH tunnel or HTTPS allowlist. Inside a private network (VPC or VNet), the tool connects to Dev, QA and Prod PostgreSQL databases, self-hosted or managed. Credentials live in a secrets manager. Public access to port 5432 is blocked.
Figure 2: The same pattern works with a Bytebase server or a CI runner, on AWS, Google Cloud, Azure, DigitalOcean or your own servers.
Building blockAWSGoogle CloudAzureDigitalOcean (our example)
Private networkVPCVPCVNetVPC
Block public database accessSecurity groupsPrivate IP only / firewall rulesPrivate access / NSGCloud firewall / trusted sources
Host for the control pointEC2, ECS or EKSCompute Engine, Cloud Run or GKEVM, Container Apps or AKSDroplet
Secure access for peopleClient VPN, SSM or a tunnelIAP or a VPNBastion or a VPNTailscale 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/bytebase

Start Bytebase

sudo mkdir -p /var/opt/bytebase
sudo docker compose up -d

For 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

  1. Open Bytebase through your tunnel or VPN and create the admin account.
  2. Under Environments, create Dev, QA and Prod.
  3. 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.
  4. Create a project and add the databases to it.
  5. 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

EnvironmentChecksWho rolls outAI agent can…
DevWarningsAutomatic when checks passPropose changes and apply them to Dev
QAErrors block the changeDeveloper or QA leadPropose changes; a person rolls out
ProdErrors block the changeDBA or tech lead, with a backupRead 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/mcp

Then 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

Six steps: an engineer asks; the AI agent reads the Dev schema and drafts SQL; SQL review and Squawk check it; it rolls out to Dev automatically; a person rolls out to QA; a DBA or tech lead rolls out to Prod.
Figure 3: The same reviewed SQL moves through every environment. The AI agent never deploys beyond Dev.

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/*.sql

Atlas 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:

  1. Freeze a baseline. Take a schema-only dump (pg_dump --schema-only) of each environment and confirm they match.
  2. Start the new tool from that baseline. Mark it as already applied so old changes are not run again.
  3. Keep the old history tables (for example flyway_schema_history or databasechangelog) for reference, then archive them.
  4. Rehearse a full cycle from Dev to QA to Prod on a copy before the first real change.
  5. 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

Licences, editions and features change often. This comparison was checked on 3 December 2026—confirm the details on each official page before you decide.

Related articles

Back to all articles