News for hackers. Stuff that matters.
Re:Bakeware – Compile Elixir applications into single execut... by l72 on Thursday September 17, 2020 @02:59PM (#24508573)
For Ecto, you can just run a function:

  migrations_path = Path.join(["#{:code.priv_dir(:myapp)}", "repo", "migrations"])
  Ecto.Migrator.run(MyApp.Repo, migrations_path, :up, all: true)
Since migrations are idempotent, and I always want to run up to the latest migration, I just include this in lib/myapp.ex in its start function. That way any time a new release rolls out, the first node with the new release automatically runs the migrations. (We always make sure our migrations are backwards compatible for at least X number of versions, which means never deleting tables or columns so that existing nodes don't break)

There are no comments on this comment yet.