Thanks for the suggestions everyone! I looked at all of them and this reply as well: Change my mind: Migrations in a start phase.
I finally decided to use a Genserver
like @axelson suggested, but ran it directly in my application supervision tree. Since I need to populate :persistent_term
with DB rows, I need the Repo
running. I could always start the repo process in another application that my main application depends on, but just running a temporary Genserver
after the Repo
process starts in the main application was simpler. Also, the Genserver
's blocking init
fn returns :ignore
once it populates :persistent_term
, so it exits normally without entering the msg receive loop. Works well for my use case