Version control for your PostgreSQL database
A simple and reliable way to manage and deploy your PostgreSQL changes with plain SQL.
Get all the latest guides, community news, product updates, and resources
Version control for your database, so you can migrate it with ease and confidence.
So you can focus on work that adds value to your organization
How does Flyway work?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();Get started with the Java API
flyway.migrate();
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
Migrate from any version of your database (including an empty one) to the next with a single command.
Plain SQL scripts (including placeholder replacement). No proprietary XML formats, no lock-in.
Use Java-based migrations for advanced data transformations and handling with LOBs.
Only requires Java 7+ and a JDBC driver
Filesystem and classpath scanning to discover SQL and Java migrations automatically.
Cluster environments are handled safely and reliably. Multiple machines can migrate in parallel.
Full support for the most popular cloud platforms: Microsoft SQL Azure, Amazon RDS, Heroku, Google Cloud Platform, and others.
Deploy PostgreSQL migrations together with application changes. Run automatically on startup via the API.
Inconsistencies and conflicts prevent launching.
Drop all objects such as tables, views, and triggers, and more from a schema without dropping the schema itself.
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.
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
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.
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.
Join the hundreds of thousands of delighted users.
Developer
Desjardins
"Flyway brings databases into the 21st century with source control management and version schemas"
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."
How does Flyway work? What are the first steps? Download Flyway