Heroku Postgres + Salesforce: migrating the database without losing sync
Move Heroku Postgres to Build with a planned data transfer, validated Salesforce sync via Stacksync, and a coordinated database cutover.
- Author
- Build.io team
- Published
- Read time
- 6 min read
To move a Heroku Postgres database that Heroku Connect syncs with Salesforce, you need the new sync running before the database switches, not after. Heroku Connect only works with Heroku Postgres, so the moment your app points at a database somewhere else, Heroku Connect stops being useful. You can move the app to Build first and keep using Heroku Postgres and Heroku Connect. When you're ready to move the database, coordinate data transfer and the handover to Stacksync, with validation before production writes switch.
This post covers the database side of that plan in more detail.

Why is a Salesforce-synced database harder to move?
A Postgres migration needs a plan for the initial copy, changes made during the move, and the final switch. An import can suit smaller databases; larger production databases usually call for replication to shorten cutover.
A database synced by Heroku Connect also receives changes from Salesforce. Salesforce records change all the time, from sales reps, automations and other integrations. Your app changes records too, and Heroku Connect sends those back to Salesforce. So during a migration you're not moving a static dataset. You're moving something that is being written to from both ends.
That changes the goal. It isn't "copy the data". It's "make sure every change, on either side, ends up in the right place before, during and after the switch."
Where does the database move to?
Build provides managed Postgres through Schema To Go, alongside your application. When you create it, import_url can pull data from your existing database. For larger production databases, agree a replication-based approach with Build engineers.
You can run the move yourself with support, work alongside Build engineers, or have us manage the migration end to end. Engineer-led migration support is included with Enterprise plans. On a joint project, Stacksync handles the agreed Salesforce sync setup and handover.
What lives in the Heroku Connect schema?
Heroku Connect keeps synced Salesforce objects in their own schema in Heroku Postgres, one table per mapped object. Alongside the Salesforce fields, it adds its own columns, such as the Salesforce record ID and fields it uses to track sync status, plus a trigger log it uses to send app writes to Salesforce.
When you migrate, decide what to do with each part:
| Part | What it is | What we usually do |
|---|---|---|
| Mapped object tables | Salesforce data your app reads | Agree with Stacksync whether to copy or repopulate them, then validate schema and data |
| Salesforce ID column | Links rows to Salesforce records | Kept, so app references still resolve |
| Heroku Connect status columns | Heroku Connect's own bookkeeping | Check for app dependencies, then retire |
| Trigger log | Heroku Connect's outbound write queue | Not needed once Stacksync handles writes |
| Your own app tables | Data that isn't from Salesforce | Migrated like any Postgres data |
The application tables and Salesforce tables need a coordinated data plan. Copying the database alone does not replace the connection that keeps Salesforce records current or sends app changes back to Salesforce.
That's why Build partners with Stacksync. Build can manage the database transfer and application migration, while Stacksync handles the replacement Salesforce sync using its Salesforce connector. Together, we agree how the tables are populated, validate the data and coordinate the handover. Your team gets a path off Heroku without having to build and maintain that integration itself.
What's the step-by-step plan?
The app and database can move separately. Follow the Build Heroku migration guide for the application sync, then plan the data move:

- 01Map the current sync and application dependencies. List objects, fields, directions, schema names, foreign keys, views, and any code that uses Heroku Connect system columns.
- 02Sync and validate the app on Build. The Heroku integration imports configuration, including the existing
DATABASE_URL. You can keep the database and Heroku Connect on Heroku at this stage. Keep workers stopped until you intend them to process production jobs. - 03Choose the data transfer method. Provision Schema To Go with
import_urlwhere appropriate. For a large production database, plan replication with Build engineers instead of relying on a long final copy. - 04Agree how Salesforce tables will be populated. Coordinate database copying or replication with Stacksync's setup. Avoid having both mechanisms write to the same target tables without an agreed plan, and preserve the identifiers and relationships your app needs.
- 05Configure and validate Stacksync safely. Compare mappings, record counts and representative records. Keep one connector responsible for production writes to Salesforce; test outbound writes in a sandbox or another agreed safe setup.
- 06Resolve schema and code differences. Check names, system columns, triggers, views and application queries before cutover.
- 07Rehearse the switch and rollback. Define any write pause, how final changes are caught up, when each connector changes direction or stops, and how writes would be reconciled if you roll back.
- 08Switch the database connection. Complete the agreed final catch-up, attach the new database as
DATABASE, stop config-var sync so it cannot restore the HerokuDATABASE_URL, and redeploy. Coordinate the Salesforce sync handover before resuming production writes. - 09Verify both directions. Confirm app changes reach Salesforce and Salesforce changes reach the app, then check background jobs and reports. Move DNS separately if traffic is still on Heroku.
- 10Observe, then decommission. Keep the agreed rollback resources and backups until the new setup is proven. Remove Heroku Connect and Heroku Postgres when they are no longer needed.
How do you avoid writes going missing during cutover?
The data plan needs to cover changes from both the app and Salesforce:
- Agree write handling before the switch. A short app write pause may be appropriate for the chosen database method. Do not treat it as a requirement for moving the app runtime to Build.
- Avoid competing writers. Coordinate database replication and Stacksync so they do not overwrite each other's target data. Only one connector should own production writes back to Salesforce.
- Plan for Salesforce changes during cutover. Validate how they are captured and applied, including retries and any backlog, before promising uninterrupted sync.
- Coordinate the connector handover. Stop Heroku Connect's outbound writes at the agreed point before enabling Stacksync's production outbound path. Verify both directions before declaring the move complete.
- Plan rollback for data as well as traffic. Keeping the old database available is not enough once new writes have landed elsewhere.

Can you move to a database other than Postgres?
Most of our customers stay on Postgres, because their app was built on it and it keeps the code changes small. Stacksync also supports other databases, so if part of your plan is to sync Salesforce somewhere else, that's worth raising with them early. Their Heroku Connect alternative page lists what it covers.
Planning a move off Heroku? Talk to Build about your migration. Run it yourself with engineering support, work alongside our team, or have us manage the migration end to end. If you're moving a database that uses Heroku Connect, we'll bring Stacksync into the plan for Salesforce sync.
FAQ
Frequently asked questions






