Before you start
1. Get your Heroku database credentials
You’ll need your Heroku Postgres connection URL. Run this command to get it:HEROKU_URL when deploying the migrator.
2. Create your PlanetScale database and get credentials
Follow the PlanetScale Postgres quickstart to create a database and generate a password. When creating the password, make sure you select the Postgres permission. Copy the Postgres connection string. This is yourPLANETSCALE_URL.
3. Check your Heroku Postgres extensions
The migrator replicates your data, but it doesn’t install Postgres extensions. You need to make sure any extensions you use on Heroku are also enabled on PlanetScale before starting the migration. Run this command to see which extensions your Heroku database uses:pg_partman is in that list, read pg_partman support before you start. It needs one manual step.
4. Check for blocking vacuum processes
The migrator creates triggers on your Heroku tables to track changes. In rare cases, a long-running autovacuum process can block trigger creation, which can also block your application’s queries. Before starting the migration, check for wraparound vacuum processes:VACUUM queries with (to prevent wraparound) in the output, wait for them to finish before starting the migration.
5. Size your PlanetScale database
Cluster size: Choose a PlanetScale cluster with similar CPU and RAM to your Heroku Postgres plan. You don’t need to get this exactly right. Resizing in PlanetScale is an online operation with no downtime, and you are only billed for the time you use. Storage: Make sure your PlanetScale database has at least twice the storage that Heroku reports using. Bucardo is not very space-efficient during migration, and Postgres disk usage can vary significantly between providers. It’s not uncommon for a database to use 50% more or less space on PlanetScale than on Heroku. Automatic vacuuming will reclaim the extra space over time after the migration completes. To check your current Heroku storage usage:6. Consider your database size and performance
The migrator uses trigger-based replication. When the migration starts, it installs triggers on your Heroku database tables to track every insert, update, and delete so changes can be replicated to PlanetScale.- Small to medium databases (under 10 million rows): You likely won’t notice any performance impact.
- Large databases (tens of millions to billions of rows): The initial data copy puts additional read load on your Heroku database. The triggers add a small amount of write overhead. If your database is already under heavy load, consider:
- Upgrade your Heroku Postgres plan temporarily. A larger plan gives your database more headroom during the migration. You can downgrade after.
- Run the migration during off-peak hours. Start the initial copy when your app has less traffic.
- Use the Pause button, but be aware of the phase. Once the dashboard shows “Your databases are in sync”, Pause Sync stops data transfer to PlanetScale while changes continue to queue. Resuming catches up cleanly. Do not pause while the dashboard still says “Copying data to PlanetScale”. Bucardo cannot resume a partial
COPY, so resuming restarts the initial copy from scratch.
7. Heroku 24-hour restart limit
Heroku restarts every dyno at least once every 24 hours. If a restart happens during the initial data copy, the copy starts over from the beginning. Copy speed varies by database, but most users can expect around 200 GB per hour. Actual throughput depends on the number and size of indexes, average row width, network conditions between Heroku and PlanetScale, and the configuration of the target database. On AWS, use the CloudFormation template. That is the default way to run the migrator outside Heroku. The aws-cloudformation templates provision an EC2 instance, build the container, and run it under systemd with no 24-hour restart. The dashboard binds to localhost only, so you reach it through an SSH or SSM tunnel. On other hosts, build and run the container yourself with the same environment variables you would set on Heroku, including index-rebuild tuning:Deploy the migrator
Deploy the migrator as a temporary Heroku app. You can use the Deploy to Heroku button in the heroku-migrator repository, or deploy manually:1
Clone the repository
2
Create a Heroku app
3
Set the required config vars
4
Deploy
5
Resize the dyno (recommended)
6
Open the dashboard
PASSWORD you set above. The username is admin.Which dyno size should I use?
The migrator runs PostgreSQL and Bucardo inside the dyno, so it needs more memory than a typical web app. Memory usage scales with both data size and write volume.- Standard-1x (512 MB): Small databases with low write volume (under 1 million rows, fewer than 20 tables).
- Standard-2x (1 GB): Databases under 50 GB with moderate write volume.
- Performance-M (2.5 GB): Databases between 50-100 GB, high write throughput, or many tables. Also use this if you see R14 memory errors on Standard-2x.
- Performance-L (14 GB): Databases over 100 GB, or any database with very high write volume. The initial copy and ongoing replication for large databases can consume several GB of RAM. Smaller dynos will OOM and crash.
How the migration works
Once you open the dashboard and click Start Migration, the process follows these steps:Step 1: Setup
The migrator copies your database structure (tables, indexes, constraints) from Heroku to PlanetScale and configures replication. This is fully automatic and typically takes a minute or two. It then stops and waits for you: no data is copied until you start the next step. Bookkeeping schemas (bucardo, _ps_migrator, pscale_extensions), extension home schemas, extension-owned tables, and tables the migrator cannot put a trigger on are excluded from the dump and the sync.
Step 2: Data sync
Click Start Data Copy to begin. All existing rows are copied from Heroku to PlanetScale (the “initial copy”). By default, secondary and unique indexes are dropped on PlanetScale before that copy and rebuilt afterward. See Faster initial copy. Once the copy and index rebuild finish, the migrator enters real-time replication mode, where every new write to your Heroku database is automatically replicated to PlanetScale. Your Heroku app continues running normally throughout this entire process. For large databases, the initial copy can take hours. The dashboard shows progress and you can safely close the browser and come back later. The Pause Sync button behaves differently depending on the phase:- While the initial copy is running (dashboard title “Copying data to PlanetScale”): Bucardo cannot resume a partial
COPY. Pausing and then resuming will restart the initial copy from scratch. - Once you reach delta replication (dashboard title “Your databases are in sync”): pausing is safe. Changes are queued while paused and apply on Resume.
Step 3: Switch traffic
When the dashboard shows your databases are in sync, you’re ready to cut over. Click Switch Traffic to block writes on your Heroku database. This runs a SQLREVOKE command that removes INSERT, UPDATE, and DELETE privileges from your Heroku database user, once for each schema being migrated:
For production apps, consider enabling Heroku maintenance mode before clicking Switch Traffic. The migrator blocks writes on the source database, but it does not update your application’s config vars, restart dynos, or verify the app against PlanetScale. Maintenance mode keeps user traffic out of the handoff window while you update and test the app.
- Tables, columns, indexes, constraints, and sequences all present and matching on PlanetScale.
- Extensions present and the same version.
- Row counts on a random sample of up to 10 tables (skipping any over 10 GB, with a 60s-per-table cap).
- Pending replication — every queued change must have been applied to PlanetScale. If you run this right after Switch Traffic, it often still reports a backlog, which fails the check. Wait a minute and re-run.
GRANT command to restore write access to your Heroku database, so your app can write to Heroku again immediately.
During Switch Traffic or Revert Switch, you may see PostgreSQL warnings about
pg_stat_statements privileges in the dashboard output. These warnings are expected on some Heroku Postgres setups and do not indicate a failure.Step 4: Complete
Once you’ve verified everything is working on PlanetScale, click Complete Migration in the dashboard. This removes the replication triggers from your Heroku database.Faster initial copy (deferred index rebuild)
You have two options for how indexes are handled during the initial copy.Option A: Deferred index rebuild (default)
This is the default behavior (DISABLE_INDEX_DEFERRAL is false). To speed up the initial copy, the migrator drops the target’s secondary and unique indexes before copying and rebuilds them after the copy completes.
How it works:
- After the schema is copied, the migrator records the exact definition of every secondary and unique index (and any foreign keys that depend on a dropped unique) in a
_ps_migratorschema on the target, then drops them. Primary keys, exclusion constraints, andREPLICA IDENTITY USING INDEXindexes are kept. - The initial copy runs against the index-light tables.
- When the copy finishes the indexes are rebuilt in parallel (
INDEX_REBUILD_WORKERSat a time). Progress and any failures are shown on the dashboard. - Once each index is rebuilt, replication resumes automatically. If any index fails, the run pauses for review so you can fix the issue and Retry Failed Indexes, or Proceed Anyway (replication resumes without the failed indexes).
INDEX_REBUILD_WORKERS, MAINTENANCE_WORK_MEM, and PARALLEL_MAINTENANCE_WORKERS. Peak memory on the target is roughly INDEX_REBUILD_WORKERS × MAINTENANCE_WORK_MEM. You can also change INDEX_REBUILD_WORKERS from the dashboard before starting the copy.
Option B: Keep all indexes in place
If you’d rather not drop and rebuild anything, setDISABLE_INDEX_DEFERRAL=true. All indexes stay in place for the entire initial copy. The trade-off is a slower initial copy, because every index is maintained row-by-row as data is copied.
When DISABLE_INDEX_DEFERRAL=true, there is no post-copy rebuild, so INDEX_REBUILD_WORKERS, MAINTENANCE_WORK_MEM, and PARALLEL_MAINTENANCE_WORKERS have no effect and the dashboard hides the index-rebuild tuning control.
pg_partman support
pg_partman is supported, with one manual step: pause pg_partman maintenance before you start, and resume it on PlanetScale after cutover. Everything else is automated. The migrator replicates your leaf partitions and recreates the partitioned parent through the schema copy. Thepartman schema is not replicated, because its config and template tables can’t be.
Right after the data copy, the migrator reads your partition configuration from the source and recreates it on PlanetScale, so maintenance keeps working after cutover. Two cases still need your attention, both reported in the Setup Log:
- Sub-partitioned sets. pg_partman’s own dump function covers single-level sets only, so if you use sub-partitioning (
partman.part_config_sub) re-register those by hand after cutover. - A partition set that failed to register on PlanetScale. This shows as a warning and does not stop the migration; all your data is still copied. Only pg_partman’s settings for that table are missing on PlanetScale, so no new partitions will be created for it until you register it again with
partman.create_parent()after cutover, using the same settings as on Heroku.
Cleanup
After completing the migration:- Delete the migration app:
heroku apps:destroy my-migration - Remove the Heroku Postgres add-on from your main app when you’re confident everything is working.
0.
Running another migration
If you want to run another migration test after finishing one:- Create a fresh PlanetScale target (database/branch and credentials) and use that as the new
PLANETSCALE_URL. - Keep or reset
HEROKU_URLdepending on your source test dataset. - Update the migrator app config vars:
- Open the dashboard and start a new run.

