1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 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 String.downcase(List.last(module)) == task
34 IO.puts("The task #{task} does not exist")
39 Mix.Tasks.Pleroma.Ecto.Migrate.run(args)
43 Mix.Tasks.Pleroma.Ecto.Rollback.run(args)
47 Application.load(:pleroma)
49 case @repo.__adapter__.storage_up(@repo.config) do
51 IO.puts("The database for #{inspect(@repo)} has been created")
53 {:error, :already_up} ->
54 IO.puts("The database for #{inspect(@repo)} has already been created")
56 {:error, term} when is_binary(term) ->
57 IO.puts(:stderr, "The database for #{inspect(@repo)} couldn't be created: #{term}")