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

victorbjorklund
I’m showing you how you can customise the phx.new generator to give you a new Phoenix project the way YOU want it. In this post I show yo...
New
brainlid
You are storing some Phoenix LiveView state in the browser. You want to retrieve that saved state as early as possible to improve the use...
New
brainlid
There is a new community resource available on writing “Safe Ecto Migrations”. When we get a migration wrong, it can lock up your product...
New
ragamuf
A little halloween hocus-pocus on the value proposition of having a reliable test suite in place. You are not scared, are you?
New
bemesa21
Sorting and deleting many-to-many associations made easy with Ecto’s :sort_param and :delete_param options from cast_assoc, powered by Li...
New
brainlid
Dialyzer is a tool that you’ve probably heard about in the Elixir community. You may have even used it. However, adding Dialyzer to an ex...
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
New
lawik
One of the Erlang ecosystem’s spiciest nerd snipes are hot code updates. Because it can do it. In ways that almost no other runtime can.
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

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
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
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New

We're in Beta

About us Mission Statement