How to run migrations that are in a library?

One example is from a library I maintain. The library provides a mix task that when run, creates a migration in the host application. That migration calls a function in the library when the migration is run. You can see the code here. The timestamp for the migration is generated at the time of running the mix task.

I believe this is a quite common pattern in elixir libraries and most of the code in the link came from leaning on prior practise from other authors.

oban implements its migrations in a similar method to the above only you create the migration in your host application yourself. Its installation instructions are here. The timestamp of the migration is generated when you generate your migration.

3 Likes