Elixir Blog Post: Safe Ecto Migrations - Recipes and Resources

There is a new community resource available on writing “Safe Ecto Migrations”. When we get a migration wrong, it can lock up your production servers with table locks!

This 4 part guide walks through:

  • Understanding Ecto migrations and what Postgres is actually doing
  • Setting up your mix release project for running migrations
  • Recipes for safely making many common changes
  • How to safely make batch data changes
  • Includes a Github repo with samples!

I hope this becomes a valuable resource for the Elixir community!

10 Likes

Wow, just in time – my partner and I are about a month away from going live with an app deployed on Fly and managing migrations after we go into production is the thing I’m most concerned about. This series looks to be invaluable. Thank you so much!

4 Likes

Nice post @brainlid (and @dbern!) - I love ‘recipes’ in fact I keep hinting to PragProg about hoping to see a Phoenix Recipes book like Rails Recipes (which I used a lot!) - perhaps you two could pitch the idea to them? :003:

What app is it @tadasajon? I ask because I see you are in Costa Rica and I have toyed with the idea of moving there (it’s warmer than here!) hence wondering whether your app will be used by people there :lol:

2 Likes

The app is called QuizDrill and it involves Telegram bots aimed at the Indian marketplace. As for Costa Rica, I guess I should update my profile – I moved back to the US a couple of months ago. Now that winter is coming it may be time to revisit Costa Rica, however. In many ways it is paradise on Earth.

2 Likes

This is amazing, thank you for the wonderful resources and guides!

Just going to reiterate how awesome this is, reading through the GitHub repository. :heart:

For another general resource, I found the example of how to add encrypted fields to existing data in the cloak ecto docs as another good example that could be applied generally to updating preexisting data in the database.

2 Likes