Persistence and library applications - need advice

I have a open source GenServer based library application. It currently persists data in a CubDB database. I would like to migrate from CubDB to Postgres. I have used Ecto/Postgres before with a Phoenix web app, but I’m unsure of how things will work if I’m adding Ecto/Postgres to a library app.

It would be great if I could get some general pointers on the steps that I will need to take. What will users of my library need to do to support both my libraries persistence and their own persistence needs. Will there be two databases, one for my library and a separate one for the using application?

1 Like

I think the canonical example for this is the way Oban handles migrations.

Personally I have a library which just generates migrations directly into my application (codegen), but that’s because it’s intended for my own use only :slight_smile:

1 Like

Thanks for your help. The Oban approach makes sense. Oban makes use of the client application’s database. Now, my library app will take the same approach.

I had been thinking that my library would have it’s own database, which did seem troublesome. I do wonder, though, if there are any circumstances that might warrant this approach.

As an added bonus, I see that I have some use cases that are a perfect fit for Oban.

If you have no need for atomic transactions across your library and the user’s database, it could be useful for performance reasons to scale out to two physical database servers for a small subset of users that need to handle such load.

I think it would be fine in that case to make it the user’s problem, though - they can simply run the migrations on a different Ecto repo :slight_smile: