Skip to content

Instantly share code, notes, and snippets.

@nz
Created January 11, 2013 01:02
Show Gist options
  • Save nz/4507124 to your computer and use it in GitHub Desktop.
Save nz/4507124 to your computer and use it in GitHub Desktop.
Upgrading to Bonsai's production plans, from an old-architecture addon.

Bonsai production plans are now available, which you can review at http://addons.heroku.com/bonsai

If your index is created on our older architecture (before November 2012), you will need to remove and replace the addon to upgrade. We'll preserve the existing index that you have now when you remove the addon, to help make sure the transition happens smoothly.

1. Make note of your existing index URL

heroku config | grep BONSAI_INDEX_URL

2. Replace the addon

heroku addons:remove bonsai -a your-app
heroku addons:add bonsai:whatever -a your-app

Your BONSAI_INDEX_URL may have been preserved by Heroku. If not, make sure you replace it.

heroku config:add BONSAI_INDEX_URL=(value previously noted in 1.)

Your application should now be running with an updated addon plan, but still serving searches with your previous index.

3. Create a new index and reindex

We moved from provisioning a single index (BONSAI_INDEX_URL), to provisioning a cluster endpoint (BONSAI_URL). So you will need to create an index within that cluster, and then reindex your data into it.

For maximum reusability, you can set your own value for BONSAI_INDEX_URL, based on the new BONSAI_URL. You can then execute an HTTP POST to that URL to create an index, and reindex as normal.

I would do all of that in a Heroku Rails or bash console:

$ heroku run rails console
ENV['BONSAI_INDEX_URL'] = ENV['BONSAI_URL'] + "/new-index-name"
Http.post(ENV['BONSAI_INDEX_URL']
YourModel.reindex
$ heroku run bash
export BONSAI_INDEX_URL=$BONSAI_URL/your-index-name
curl -X POST $BONSAI_INDEX_URL
rake reindex

Your new index should now be all up to date and ready to serve traffic.

  1. Update your app's configuration

Once you have reindexed, you should update the relevant configurations or initializers in your application to use your new index URL. The easiest way is to update the BONSAI_INDEX_URL environment variable that you're already using.

heroku config:add BONSAI_INDEX_URL=your-new-index-full-url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment