sezaru

sezaru

How to manage migrations with multiple devs/branchs?

Ash has a pretty cool feature that will auto generate migrations for changes in the resources. This is done by having “snapshot” json files that Ash looks to find what changed from the last migration.

This works great when you are working alone in a project, but we started seeing some problems with it when we have multiple developers working in different features that will generate migrations in their branchs.

Here is an example on how to trigger the issue:

  1. Dev 1 creates a new branch based on master which has a migration snapshot (json file) A;
  2. Dev 2 also creates a new branch based on master with the same migration snapshot A;
  3. Dev 1 adds a new change to the resource and Generates a new migrations which will generate snapshot B;
  4. Dev 2 also adds a new change to the same resource and generates a new migration which will generate snapshot C;
  5. Note that both snapshot B and snapshot C are based in snapshot A;
  6. Dev 1 merges to master its branch;
  7. Dev 2 merges to master its branch;
  8. Now, if we run ash_postgres.generate_migrations, ash will create a new migration file doing the same change snapshot B did even though that migration was already created and applied to the DB.

The reason for that is because since snapshot C was created based on snapshot A instead of B, then it doesn’t knows about snapshot B and it doesn’t knows about its changes, so it will assume that they don’t exists and will create a new migration with these changes again.

The way that we are working around this issue here in my project is that when we are ready to merge a branch that has migration changes to master, we delete all the migrations we did, we update the branch to the latest master commit, and recreate the migrations and do the merge.

That way, as long as no one else is merging to master at the same time, this will guarantee that we will have correct migration being created.

So, the question is, is there a better way to handle that or some other command/workaround for it?

Most Liked

zachdaniel

zachdaniel

Creator of Ash

There is currently no workaround for this, unfortunately. There is, however, a better design that can be implemented in ash_postgres to make this unnecessary. We just haven’t had a chance to implement it. Redesign "snapshots" to be "operations" · Issue #75 · ash-project/ash_postgres · GitHub

This is a good example of the kind of things I intend to focus on after 3.0 comes out, as it will be a big quality of life improvement.

Where Next?

Popular in Questions Top

Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
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
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
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
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

We're in Beta

About us Mission Statement