1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-onl
5 defmodule Mix.Tasks.Pleroma.Ecto.Rollback do
9 @shortdoc "Wrapper on `ecto.rollback` task"
23 migrations_path: :string
27 Changes `Logger` level to `:info` before start rollback.
28 Changes level back when rollback ends.
32 mix pleroma.ecto.rollback
35 - see https://hexdocs.pm/ecto/2.0.0/Mix.Tasks.Ecto.Rollback.html
39 def run(args \\ []) do
41 {opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
43 if Application.get_env(:pleroma, Pleroma.Repo)[:ssl] do
44 Application.ensure_all_started(:ssl)
48 if opts[:to] || opts[:step] || opts[:all],
50 else: Keyword.put(opts, :step, 1)
54 do: Keyword.merge(opts, log: false, log_sql: false),
57 path = Mix.Tasks.Pleroma.Ecto.ensure_migrations_path(Pleroma.Repo, opts)
59 level = Logger.level()
60 Logger.configure(level: :info)
62 if Pleroma.Config.get(:env) == :test do
63 Logger.info("Rollback succesfully")
66 Ecto.Migrator.with_repo(Pleroma.Repo, &Ecto.Migrator.run(&1, path, :down, opts))
69 Logger.configure(level: level)