Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Ecto from existing Phoenix project

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
like image 812
the100rabh Avatar asked Jul 21 '16 07:07

the100rabh


2 Answers

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.

like image 183
Ole Spaarmann Avatar answered Dec 17 '22 07:12

Ole Spaarmann


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.

like image 36
Tom Avatar answered Dec 17 '22 07:12

Tom