6
votes

I have an existing project built with default settings. Now I see that I dont really need Ecto for anything. I just want to remove all DB related events from the code.

Can someone guide me through the process ?

I have removed all mention of Ecto from mix.exs but I guess thats not enough

Update:

I found ecto mentioned in lib/api_test/repo.ex file. If I remove the line it gives the following error

=INFO REPORT==== 21-Jul-2016::12:43:30 ===
    application: logger
    exited: stopped
    type: temporary
** (Mix) Could not start application api_test: ApiTest.start(:normal, []) returned an error: shutdown: failed to start child: ApiTest.Repo
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function ApiTest.Repo.start_link/0 is undefined or private
            (api_loc) ApiTest.Repo.start_link()
            (stdlib) supervisor.erl:365: :supervisor.do_start_child/2
            (stdlib) supervisor.erl:348: :supervisor.start_children/3
            (stdlib) supervisor.erl:314: :supervisor.init_children/2
            (stdlib) gen_server.erl:328: :gen_server.init_it/6
            (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
3
I will start removing phoenix_ecto from the deps and look where the compiler start complaining. The compiler where not complaining after deleting ecto from mix.exs ? - user2637826
You could create a new phoenix project with the --no-ecto flag and then compare it to your existing one. - Ole Spaarmann
Do you still have a line such as worker(ApiTest.Repo, args), mentioned somewhere? See if Repo is still mentioned somewhere in your project. - helios35

3 Answers

15
votes

I think I have a good solution for you. I created two fresh Phoenix projects, one with Ecto, one with the --no-ecto flag (mix phoenix.new --no-ecto my_app). I then initialised a Git repo in the one with Ecto, added and commited everything and then deleted all files and replaced them with the ones from the project without Ecto.

The result is this commit on GitHub. I think there you find a very good starting point on what to change.

3
votes

This can now be done with mix ecto.drop -r MyApp.Repo (where MyApp is the name of the application). See the guides for ecto.drop.

Additionally this could be done manually by deleting MyApp.Repo and the reference in lib/my_app/application.ex under the start function.

0
votes

Got it done.

Basically followed the documentation of Phoenix for including Ecto mentioned at https://hexdocs.pm/phoenix/1.3.0-rc.2/ecto_models.html

Just did the reverse of whatever was mentioned in the document.