Skip to content

Instantly share code, notes, and snippets.

@stoft
Created July 13, 2015 21:06
Show Gist options
  • Save stoft/43572de1f8b387e62721 to your computer and use it in GitHub Desktop.
Save stoft/43572de1f8b387e62721 to your computer and use it in GitHub Desktop.
Ecto touchpoints in Phoenix
# These are most of the Ecto touchpoints within Phoenix.
# I may have missed a few though.
# /
## mix.exs
:postgrex, :phoenix_ecto
# web/
## web.ex
* controller & channel
alias MyApp.Repo
import Ecto.Model
import Ecto.Query, only: [from: 2]
# test/
## test_helper.ex
Mix.Task.run "ecto.create", ["--quiet"]
Mix.Task.run "ecto.migrate", ["--quiet"]
Ecto.Adapters.SQL.begin_test_transaction(MyApp.Repo)
## model_case.ex & conn_case.ex & channel_case.ex
alias MyApp.Repo
import Ecto.Model
import Ecto.Query, only: [from: 2]
unless tags[:async] do
Ecto.Adapters.SQL.restart_test_transaction(MyApp.Repo, [])
end
# lib/
## my_app/repo.ex
use Ecto.Repo, otp_app: :my_app
## my_app.ex
worker(MyApp.Repo, []),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment