New! – Spin up instant copies of your dev databases in the cloud for free Learn more

Flyway PostgreSQL

Flyway

Version control for your PostgreSQL database

A simple and reliable way to manage and deploy your PostgreSQL changes with plain SQL.

Get started with Flyway

Stay updated about Flyway

Get all the latest guides, community news, product updates, and resources

In 2020, we helped

34,000 PostgreSQL users manage and deploy database changes with Flyway

Database migrations made easy

Version control for your database, so you can migrate it with ease and confidence.

Easy to use

Reclaim control of your PostgreSQL migration process

Why database migrations?

Simplify deployments

So you can focus on work that adds value to your organization

How does Flyway work?

Designed for CI/CD

Automate Flyway for hassle-free releases

Get started with Flyway

Always up to date

Supports the latest PostgreSQL versions from 9.0 - 13

See all supported versions
Get going with Flyway in under in 5 minutes

For non-JVM users and environments without build tools

$ flyway migrate -url=... -user=... -password=...
Get started with the command line tool

Migrate directly from within your application

Flyway flyway = Flyway.configure().dataSource(url, user, password).load(); 
flyway.migrate();
Get started with the Java API

Seamless integration with Maven 2/3 builds

> mvn flyway:migrate -Dflyway.url=... -Dflyway.user=... -Dflyway.password=...
Get started with Maven 2/3 builds

Seamless integration with Gradle builds

> gradle flywayMigrate -Dflyway.url=... -Dflyway.user=... -Dflyway.password=...
Get started with the Gradle plugin

It just works. Refreshingly simple.

Migrate from any version of your database (including an empty one) to the next with a single command.

Uses plain SQL

Plain SQL scripts (including placeholder replacement). No proprietary XML formats, no lock-in.

No restrictions

Use Java-based migrations for advanced data transformations and handling with LOBs.

No dependencies

Only requires Java 7+ and a JDBC driver

Convention over configuration

Filesystem and classpath scanning to discover SQL and Java migrations automatically.

High reliability

Cluster environments are handled safely and reliably. Multiple machines can migrate in parallel.

Cloud support

Full support for the most popular cloud platforms: Microsoft SQL Azure, Amazon RDS, Heroku, Google Cloud Platform, and others.

Auto-migration on startup

Deploy PostgreSQL migrations together with application changes. Run automatically on startup via the API.

Fail fast

Inconsistencies and conflicts prevent launching.

Quick reset

Drop all objects such as tables, views, and triggers, and more from a schema without dropping the schema itself.

Frequently asked questions

How do you migrate a PostgreSQL database?

If you are attempting to create a new database as part of a software deployment, the easiest way to migrate a PostgreSQL database is through the SQL commands that can create the tables and other structures within it.

How do you create PostgreSQL scripts to recreate or migrate a database?

You can always connect to the PostgreSQL server using bash or some other command line tool. From there, running the pg_dump utility will allow you to export a script into a .SQL file. The command would need the -s to ensure it’s only the schema and not the data as well:

pg_dump -R postgres -s mydatabasename

How do you write a repeatable procedure script in PostgreSQL?

If you want to be able to repeatedly run a stored procedure creation script, you need to alter your CREATE command as follows:

CREATE OR REPLACE PROCEDURE public.ProcName...

The phrase "CREATE OR REPLACE" can be used with a number of other objects as well. These include FUNCTION, VIEW and others.

How do you create scripts for multiple databases in PostgreSQL?

If you want to create the kind of files used in pg_dump for multiple databases, you need to use the pg_dumpall utility. Alternatively, you simply run pg_dump multiple times. However, pg_dumpall will also create scripts for global objects where pg_dump will only script out a single database.

Flyway supports PostgreSQL

Along with 20+ other relational databases.

Oracle
MySQL
Aurora MySQL
MariaDB
Percona XtraDB cluster
SQL Server
PostgreSQL
Aurora PostgreSQL
Redshift
CockroachDB
DB2
SAP HANA
Sybase ASE
Informix
HSQLDB
H2
Derby
Snowflake
SQLite
Firebird

Here's what our users are saying

Join the hundreds of thousands of delighted users.

Desjardins logo

Developer

Desjardins

"Flyway brings databases into the 21st century with source control management and version schemas"

Read the full story from Desjardins

Carlos Robles

Carlos Robles

Data Platform MVP & Flyway expert

"My favorite thing about Flyway is the simplicity. I think this is key when you want to embrace migrations-based deployment, because you want to keep things simple, right? And believe me – Flyway is the right tool for that job."

Watch Carlos Robles' 30-minute webinar

Ready to get started?

Get started with Flyway

How does Flyway work? What are the first steps? Download Flyway