Why am I seeing errors after a Salesforce Sandbox Refresh?

Issue

Your Salesforce Sandbox Organization has gone through a refresh and now you're having trouble with Heroku Connect. You may:

  • see errors when editing mappings
  • not be able to add columns to a mapping (e.g., the columns do not appear when editing the mapping)
  • see errors writing changes to your organization
  • notice problems synchronizing changes from Salesforce

When a sandbox organization is refreshed, Salesforce essentially gives you a new organization. This breaks the connection between your Salesforce database and your Heroku Postgres database. It's different from a production instance refresh because your record's SFIDs change, which can cause consequences not only for Heroku Connect's synchronization but for your data.

Resolution

The best way to recover from a sandbox refresh is to export your connection configuration and create a new connection to your new organization. If you would like to continue using the same schema for your new connection you will need to ensure the schema has no tables or does not exist, otherwise you'll need to pick a new schema to use.

To export your config for an existing connection follow these instructions:

  1. First export your connection configuration.

    You can export it via the dashboard by viewing your connection on https://connect.heroku.com, clicking "Settings" and selecting "Import/Export Configuration" from its dropdown. Once there click the "Export" button and follow the rest of the steps.

    Alternatively, you can use the Heroku Connect CLI Plugin:

    $ heroku connect:export -a application
    

    At this point you should have a file ending in .json with your configuration.

  2. Destroy the exiting Heroku Connect add-on.

    You can destroy the add-on via your Application Dashboard or via the Heroku CLI:

    $ heroku addons:destroy herokuconnect -a application
    
  3. Create a new Heroku Connect add-on and open the Connect dashboard:

    $ heroku addons:create herokuconnect -a application
    $ heroku addons:open herokuconnect -a application
    
  4. Authorize Heroku Connect to use your new Sandbox Organization.

  5. Import your old connection configuration.

    You can import it via the dashboard by viewing your connection on https://connect.heroku.com, clicking "Settings" and selecting "Import/Export Configuration" from its dropdown. Once there click the "Import" button and follow the rest of the steps to upload the file you downloaded in Step 1.

    Alternatively, you can use the Heroku Connect CLI Plugin:

    $ heroku connect:import -a application application-herokuconnect-concave-12345.json