Skip Navigation
Show nav
Heroku Dev Center Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
Heroku Dev Center Dev Center
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log in or Sign up
View categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
    • Buildpacks
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Node.js Behavior in Heroku
      • Troubleshooting Node.js Apps
      • Working with Node.js
    • Ruby
      • Rails Support
        • Working with Rails
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • Working with PHP
      • PHP Behavior in Heroku
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
    • Heroku Inference
      • Heroku Inference Quick Start Guides
      • AI Models
      • Inference Essentials
      • Inference API
    • Tool Use
    • Vector Database
    • AI Integrations
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
    • Heroku AppLink
      • Heroku AppLink Reference
      • Working with Heroku AppLink
      • Getting Started with Heroku AppLink
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Other Salesforce Integrations
  • Databases & Data Management
  • Heroku Postgres
  • Postgres Basics
  • Testing PostgreSQL Major Version Upgrades

Testing PostgreSQL Major Version Upgrades

English — 日本語に切り替える

Table of Contents [expand]

  • Dry Run Method
  • Fork Method
  • Copy Method

Last updated October 27, 2025

Heroku recommends testing major Postgres version upgrades for your Heroku Postgres add-ons before completing the upgrade in your production database.

Testing version upgrades helps identify and resolve any possible upgrade errors or incompatibility issues that could impact your database or application. Testing also helps reduce the downtime for your application when you’re upgrading the production database so you can address any issues in advance.

The most common upgrade issues are related to type incompatibilities between Postgres versions, object reference or dependency errors, or general application problems when an app or its PostgreSQL driver version doesn’t support the target Postgres version.

There are two methods for testing a version upgrade:

  • Dry Run Method (only available for Standard-tier and higher leader databases): Tests the database’s schema and data compatibility with the Postgres version. Useful to get an estimate of how long the upgrade takes to complete.
  • Fork or Copy Method: Tests your app’s compatibility and performance with the new Postgres version. Useful for end-to-end testing.

Dry Run Method

We recommend using the Direct upgrade method for all Heroku Postgres version upgrades, but you can only test an upgrade with pg:upgrade:dryrun on Standard-tier and higher leader databases. For Essential-tier databases, test with pg:copy.

The pg:upgrade:dryrun command lets you test the Postgres version upgrade to ensure that your database schema is compatible with the target version. It also gives you an estimate for the time required to upgrade a particular database.

The pg:upgrade:dryrun command simulates a version upgrade by creating and upgrading a temporary follower database with PostgreSQL’s pg_upgrade utility. The temporary follower is only for the version upgrade and isn’t the same as a normal follower you create. You can’t access the temporary follower during the dry run, and it doesn’t incur extra costs. Heroku sends the results of the test upgrade and how long the upgrade took via email. We immediately deprovision the follower after the test upgrade finishes. The process of creating the temporary follower can take hours while the actual dry run can take around 10 minutes.

You can’t access the follower database the command creates. If you want to test the upgraded database against your app, test using the forked database method instead.

$ heroku pg:upgrade:dryrun HEROKU_POSTGRESQL_RED --app example-app
› Warning: This command starts a test upgrade for postgresql-lively-15649 to the latest supported Postgres version.

To proceed, type example-app or re-run this command with --confirm example-app: example-app
Starting a test upgrade on postgresql-lively-15649... done
Started test upgrade. We'll notify you via email when it's complete.

After testing, you can start the version upgrade on the leader database with pg:upgrade:prepare.

Fork Method

Testing a Postgres version upgrade with a database fork requires app downtime on the order of 30 minutes. If your upgrade takes longer than 30 minutes, open a Support ticket.

Using the forked database method lets you test the upgraded database on your app to ensure compatibility and performance. This method is recommended for testing the Direct and Follower Failover upgrade methods. This method is available for Standard-tier and higher plans that support the fork feature.

First, fork your existing production database on a staging or non-production app to run and validate the complete upgrade process:

$ heroku addons:create heroku-postgresql:<database_plan> --as TEST_UPGRADE_DATABASE -a staging_app_name -- --fork production_app_name::DATABASE_URL

When the forked database is ready, start the Direct upgrade on your fork.

To complete the database version upgrade test, promote the upgraded database as the primary database for your non-production application. Verify that your application can connect and communicate with the database as expected.

$ heroku pg:promote TEST_UPGRADE_DATABASE --app staging_app_name

This approach lets you test the complete upgrade process and estimate how long your upgrade takes when you upgrade in production. This process is also helpful to confirm that your application is compatible with the new PG version, which is the case unless your application uses an old PostgreSQL client or driver.

When you’re finished testing the upgrade, you can delete the forked database and the upgraded follower.

Alternative Testing Approach

To speed up the version upgrade testing process, another approach is to create a follower of your production application in a non-production environment. You can run pg:upgrade:run on the follower directly. This command unfollows the leader and performs the Postgres upgrade to the target version.

Promote the upgraded database as the primary database in your non-production environment to verify that your application is compatible with the new version.

Copy Method

Use the pg:copy method to upgrade the Postgres versions of databases under 10 GB. You can use pg:copy to test the version upgrade on all Heroku Postgres plans. The copy method is recommended for Essential-tier databases, which don’t support the fork feature.

Using the copy method lets you test the upgraded database on your app to ensure compatibility and performance. This method is recommended for testing version upgrades on Essential-tier databases that use the Direct upgrade or the Data Copy upgrade methods.

Performing a Postgres version upgrade with pg:copy requires downtime of about 3 minutes per GB, although this amount can vary substantially.

To test the upgrade process, provision a new database on a non-production application, specifying the target Postgres version:

$ heroku addons:create heroku-postgresql:<database_plan> --as DATABASE_UPGRADE_TEST --app staging_app_name -- --version=16

When the new database is available, copy the data from your production database to the new database:

$ heroku pg:copy production_app_name::DATABASE_URL DATABASE_UPGRADE_TEST --app staging_app_name

After the data copy finishes, promote the database to your non-production application to verify that your application is compatible with the new version:

$ heroku pg:promote DATABASE_UPGRADE_TEST --app staging_app_name

If the data copy process fails, check the error details in the logs available through heroku pg:backups:info <COPY_ID>.

Keep Reading

  • Upgrading the Version of a Heroku Postgres Database
  • Heroku Postgres
  • Choosing the Right Heroku Postgres Plan
  • Managing Heroku Postgres using the CLI
  • Heroku Postgres Version Support

Or explore the Postgres Basics category.

Feedback

Log in to submit feedback.

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices