Strategies for Migrating a Phoenix App on Heroku

For those of you deployed on Heroku, here are a few migration strategies that might save you some time.

1 Like

At ClubCollect we usually use release phase to do migrations, so our procfile looks like this:

web: yes | mix compile.protocols && elixir --sname dyno -pa _build/prod/consolidated -S mix phoenix.server
release: mix ecto.migrate

Release is a beta feature, but it didn’t fail us :slight_smile:


I didn’t even know that was a feature. That’ll be very useful to add to my procfiles!

1 Like

Usually yes | is not such a great idea with BEAM - it will buffer the stdin, so you’re potentially buffering an infinite sequence of yeses. This caused me issues couple times.

@michalmuskala Is there a way around it?

You can probably do:

yes | head -n 1 | mix...

I don’t see a reason for yes | in that command in the first place… Neither compile.protocols, nor phoenix.server are interactive commands.

Another thing is that since 1.2, whenever application is configured as build_embedded: true the protocol consolidation happens automatically.

In your Procfile you have MIX_ENV=prod. That’s unnecessary since it’s the buildpack default, if you need another MIX_ENV you should set it in the Heroku config.