1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-onl
5 defmodule Mix.Tasks.Pleroma.Ecto.Migrate do
10 @shortdoc "Wrapper on `ecto.migrate` task."
23 strict_version_order: :boolean,
24 migrations_path: :string
28 Changes `Logger` level to `:info` before start migration.
29 Changes level back when migration ends.
33 mix pleroma.ecto.migrate [OPTIONS]
36 - see https://hexdocs.pm/ecto/2.0.0/Mix.Tasks.Ecto.Migrate.html
40 def run(args \\ []) do
42 {opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
45 if opts[:to] || opts[:step] || opts[:all],
47 else: Keyword.put(opts, :all, true)
51 do: Keyword.merge(opts, log: false, log_sql: false),
54 path = Mix.Tasks.Pleroma.Ecto.ensure_migrations_path(Pleroma.Repo, opts)
56 level = Logger.level()
57 Logger.configure(level: :info)
59 {:ok, _, _} = Ecto.Migrator.with_repo(Pleroma.Repo, &Ecto.Migrator.run(&1, path, :up, opts))
61 Logger.configure(level: level)