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, [])

    IO.puts("Populated database seed data...")

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.

Mix.EctoSQL was always private and should not be invoked directly. There is now a public API for this: https://github.com/elixir-ecto/ecto_sql/pull/113


Thank you @josevalim, this was exactly what I was looking for! Much obliged.