1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.ReleaseTasks do
9 [task | args] = String.split(args)
12 "migrate" -> migrate(args)
14 "rollback" -> rollback(args)
15 task -> mix_task(task, args)
19 defp mix_task(task, args) do
20 Application.load(:pleroma)
21 {:ok, modules} = :application.get_key(:pleroma, :modules)
24 Enum.find(modules, fn module ->
25 module = Module.split(module)
27 match?(["Mix", "Tasks", "Pleroma" | _], module) and
28 task_match?(module, task)
34 IO.puts("The task #{task} does not exist")
38 defp task_match?(["Mix", "Tasks", "Pleroma" | module_path], task) do
42 |> String.equivalent?(String.downcase(task))
46 Mix.Tasks.Pleroma.Ecto.Migrate.run(args)
50 Mix.Tasks.Pleroma.Ecto.Rollback.run(args)
54 Application.load(:pleroma)
56 case @repo.__adapter__.storage_up(@repo.config) do
58 IO.puts("The database for #{inspect(@repo)} has been created")
60 {:error, :already_up} ->
61 IO.puts("The database for #{inspect(@repo)} has already been created")
63 {:error, term} when is_binary(term) ->
66 "The database for #{inspect(@repo)} couldn't be created: #{inspect(term)}"