{:ok, _} = Application.ensure_all_started(:pleroma)
end
+ def load_pleroma do
+ Application.load(:pleroma)
+ end
+
def get_option(options, opt, prompt, defval \\ nil, defname \\ nil) do
Keyword.get(options, opt) || shell_prompt(prompt, defval, defname)
end
def ensure_migrations_path(repo, opts) do
path = opts[:migrations_path] || Path.join(source_repo_priv(repo), "migrations")
+ path =
+ case Path.type(path) do
+ :relative ->
+ Path.join(Application.app_dir(:pleroma), path)
+
+ :absolute ->
+ path
+ end
+
if not File.dir?(path) do
raise_missing_migrations(Path.relative_to_cwd(path), repo)
end
def source_repo_priv(repo) do
config = repo.config()
priv = config[:priv] || "priv/#{repo |> Module.split() |> List.last() |> Macro.underscore()}"
- Path.join(File.cwd!(), priv)
+ Path.join(Application.app_dir(:pleroma), priv)
end
defp raise_missing_migrations(path, repo) do
defmodule Mix.Tasks.Pleroma.Ecto.Migrate do
use Mix.Task
+ import Mix.Pleroma
require Logger
@shortdoc "Wrapper on `ecto.migrate` task."
@impl true
def run(args \\ []) do
+ load_pleroma()
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
opts =
defmodule Mix.Tasks.Pleroma.Ecto.Rollback do
use Mix.Task
+ import Mix.Pleroma
require Logger
@shortdoc "Wrapper on `ecto.rollback` task"
@impl true
def run(args \\ []) do
+ load_pleroma()
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
opts =