brainlid

brainlid

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!

Most Liked

tadasajon

tadasajon

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!

AstonJ

AstonJ

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:

tadasajon

tadasajon

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.

f0rest8

f0rest8

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.

Where Next?

Popular in Blog Posts Top

brainlid
Phoenix 1.7.0 brings a lot of new things when we run mix phx.gen my_app. These new and cool ways of doing things aren’t automatically bro...
New
New
marcelo
Long story short, over the past years we’ve been scaling our operation quite a lot at Unbabel. Most of our codebase is Python and some of...
New
paulanthonywilson
All a bit meta, but this is a quick post on creating a Jekyll blog post from a Livebook page. Posted via Devtalk (see this thread for ...
New
New
New
brainlid
I love LiveView. Navigating between views is so fast! This quick tip makes navigating feel instantaneous by adding a split-second delay b...
New
ConnorRigby
Just finished a post for Embedded Elixir and I thought it should be cross-posted here: I’ll update this thread as posts get published. ...
New
mssantosdev
Our take on how to build a frontend style guide with Phoenix Components, Atomic Design and plain CSS, with focus on reusability and code ...
New
SmartLogic
Season four of the Elixir Wizards podcast launches today! This season we’re focused on system and application architecture. We’ll be doin...
New

Other popular topics Top

belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New

We're in Beta

About us Mission Statement