treble37
With Ecto 3.1, can you still use ensure_started if importing Mix.EctoSQL?
So recently, we upgraded to Ecto 3.1 (and started making the app multi-node). Looking at Mix.EctoSQL in ecto_sql repository, it seems like you can use ensure_started/2. (Note: this code was working previously, but was recently just discovered to have stopped working). I have code that I want to run as a custom distillery command:
defmodule Demo.ReleaseTask do
@moduledoc """
A module for seeding data during release...
"""
import Mix.EctoSQL
@start_apps [:logger, :ssl, :postgrex, :ecto, :ecto_sql, :ex_machina]
def bootstrap_and_init do
IO.puts("Starting dependencies...")
Enum.each(@start_apps, &Application.ensure_all_started/1)
IO.puts("Starting data repo(s)...")
ensure_started(Demo.Repo, [])
Demo.Seed.Document.seed()
IO.puts("Populated database seed data...")
:init.stop()
end
end
Currently, when calling Demo.Seed.Document.seed(), I end up getting something like ** (EXIT from #PID<0.91.0>) shutdown. When I tried extracting a more informed message from the EXIT and printed it out, it said the “repo was not running”. Is there a way to spin up the Repo and keep it running long enough to populate data? I should add the Demo.Seed.Document.seed/0 is using ex_machina to insert the data via a factory.
Most Liked
josevalim
Mix.EctoSQL was always private and should not be invoked directly. There is now a public API for this: Add Ecto.Migrator.with_repo/2 to start/stop apps for migrations by josevalim · Pull Request #113 · elixir-ecto/ecto_sql · GitHub
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









