Hi all! Trying to follow the docs to get a testing sandbox setup with a project that already has a functioning Ecto database.
Upon mix test I’m getting -
**[info] Migrations already up
(UndefinedFunctionError) function PhotoGrid.Repo.get_dynamic_repo/0 is undefined (module PhotoGrid.Repo is not available)
PhotoGrid.Repo.get_dynamic_repo()
I believe I have the naming convention wrong for this test repo, but I don’t know what it’s supposed to be. Following the docs, the convention seems to be MyApp.Repo, my app’s name is PhotoGrid. I understand the naming convention for the existing Ecto database is different. For example-
No, I didn’t explicitly make a PhotoGrid.Repo. That’s part of my confusion with the docs- I didn’t quite understand if in this setup Ecto was doing any work behind the scenes to essentially create a sandbox that’s PhotoGrid.Repo , separate from my real data existing in Posts.Repo. Perhaps I misunderstood the whole abstraction
I suppose it should just be Posts.Repo for everything like I have in config/config.exs, correct?
Thanks for your helpful questions and sanity check !
Find all occurences of use Ecto.Repo in your code. Any modules that match that are a candidate for usage in DB operations. If a module does not have use Ecto.Repo inside then you can’t use it for DB operations.
It was just by prepending the appropriate calls of .Repo with Posts. This was confirmed by your reminder of what’s available Repo wise with what already exists with use Ecto.Repo .