Correct mix task source for mongodb_ecto

27 views
Skip to first unread message

Joe Pearson

unread,
Aug 4, 2021, 8:28:16 PM8/4/21
to elixir-ecto

Hi folks!

I'm pitching in on adding Ecto 3 support for the ecto_mongodb package.  I have a question about mix tasks:


What is the best/correct thing for an ecto adapter to do in order to provide these useful mix tasks to users?  Should I pull in those mix tasks to mongodb_ecto or should I instead add ecto_sql as a dependency and attempt as far as possible to re-use the tasks (I'm not sure if this is entirely possible yet but it seems like it might be, apart from the docs which are SQL specific)?

I ask since the tasks themselves would be largely duplicated between mongodb_ecto and ecto_sql but perhaps that's unavoidable for now.

Thanks for your help!  Joe

José Valim

unread,
Aug 5, 2021, 3:58:07 AM8/5/21
to elixi...@googlegroups.com
When I moved migrations to Ecto SQL, I talked with mongo maintainers at the time and they said migrations were mostly not useful for mongo. They are used for index management, for example, and they said there could be other approaches for ensuring those indexes in prod. For example, you could run a Task when your app starts that ensures certain indexes and properties exist. Has the situation changed today?

--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/29bfc083-5611-4fc5-ad5e-c077c1a108c7n%40googlegroups.com.

Joe Pearson

unread,
Aug 5, 2021, 10:34:22 AM8/5/21
to elixir-ecto
Thanks for the context, that helps!  I got tripped up slightly by the way the documentation is arranged which suggested it ought to be possible to run, for example, mix ecto.gen.migration xyz, but since those tasks are now in the ecto_sql repo they were no longer present.

The situation is roughly the same as far as I know.  It seems like being able to arrange migration scripts (even if limited to index management) in a similar way to that of ecto_sql could still be useful, and might make a good vehicle for other Mongo features like schema.  The mix tasks for dumping / loading are similarly useful too (perhaps using mongodump / mongorestore). 

This wouldn't preclude running a Task on startup if needed.  I have also wondered about supporting some sort of "declare indexes" functionality that would allow a user to define the indexes they want and have the adapter take care of managing the creation / removal of them under the hood to match.

At the risk of creating huge amounts of work for myself... has an `ecto_nosql` project been considered?

Any other guidance / tips / recommendations on the best way of proceeding with this and in general with helping to get ecto_mongo back on track are much appreciated.

José Valim

unread,
Aug 5, 2021, 10:46:15 AM8/5/21
to elixi...@googlegroups.com
If your goal is to get ecto_mongo back, I would focus on everything else and leave migrations for last. I feel like there are simpler approaches that do not require the whole transactional migrations machinery.

Joe Pearson

unread,
Aug 5, 2021, 6:25:32 PM8/5/21
to elixir-ecto
It is and yes I agree.

Thanks for your help.
Reply all
Reply to author
Forward
0 new messages