Mix task which runs Ecto migrations automatically when switching branches in git

Hello everyone,

Here is a mix task which runs Ecto migrations automatically when switching between branches using git:

This is useful to me when working on a Phoenix Framework project where the schema is changing often and I have to switch between branches often to test other developers PRs. In this situation I want to keep my local instance’s data mostly in tact vs. rebuild my db from scratch each time and have a quick way to rollback and migrate forward.

Any feedback is welcome, I’m curious if anyone else would find it useful or if there’s an existing tool people use for the same purpose.

2 Likes