Elixir module which can autogenerate migrations when included into an existing Umbrella app

Hello everyone,

I wondered if it was possible (and have googled for this a lot) to make a module which will share the same database as the rest of an Umbrella app which includes this module? Using a context such as “market”.

For example on Rails there is Devise which can install the necessary tables inside your existing database in your existing project. I would like my module to have the same kind of ability but not sure where to start with that?

On the Elixir Slack group I asked for help to do with this and got some really useful pointers:

“usually your app would generate the migrations via a mix task into the users project folder”

And:

“I would consider just put a list of all needed fields for your app to work, make user create own migrations, and make schemas configurable. Hope that makes sense”

I just wondered if anyone knew how I could possibly create a mix task which would generate the migrations for the user but would thus permit them to edit the migrations if needed before running migrate?

I have tried googling for this but so far have not found any answers which have helped with this. I would appreciate any pointers :slight_smile:

Thanks for all the support I have received so far from the Elixir community!

I just happened to be looking for advice on the same thing.

Check out https://github.com/aseigo/authpipe/blob/master/lib/mix/authpipe.gen_ectopassword_migration.ex for a fairly easy to understand example of someone doing something similar. It’s a mix task that adds the migrations to the consumer app.

2 Likes

Many thanks for this!