Skip to content
Snippets Groups Projects
Verified Commit 16a5d7e2 authored by Alex Gleason's avatar Alex Gleason
Browse files

migrate_to_db --force

parent 3a2b2cb6
Branches pleroma-mrf-silence
No related tags found
No related merge requests found
Pipeline #28732 failed
......@@ -5,18 +5,18 @@
## Transfer config from file to DB.
!!! note
You need to add the following to your config before executing this command:
You should add the following to your config before executing this command:
```elixir
config :pleroma, configurable_from_database: true
```
```sh tab="OTP"
./bin/pleroma_ctl config migrate_to_db
./bin/pleroma_ctl config migrate_to_db [-f | --force]
```
```sh tab="From Source"
mix pleroma.config migrate_to_db
mix pleroma.config migrate_to_db [-f | --force]
```
......
......@@ -13,9 +13,16 @@ defmodule Mix.Tasks.Pleroma.Config do
@shortdoc "Manages the location of the config"
@moduledoc File.read!("docs/administration/CLI_tasks/config.md")
def run(["migrate_to_db"]) do
def run(["migrate_to_db" | options]) do
start_pleroma()
migrate_to_db()
{opts, _} =
OptionParser.parse!(options,
strict: [force: :boolean],
aliases: [f: :force]
)
migrate_to_db(opts)
end
def run(["migrate_from_db" | options]) do
......@@ -30,18 +37,14 @@ def run(["migrate_from_db" | options]) do
migrate_from_db(opts)
end
@spec migrate_to_db(Path.t() | nil) :: any()
def migrate_to_db(file_path \\ nil) do
if Pleroma.Config.get([:configurable_from_database]) do
@spec migrate_to_db(map()) :: any()
def migrate_to_db(opts) do
if Pleroma.Config.get([:configurable_from_database]) || opts[:force] do
config_file =
if file_path do
file_path
if Pleroma.Config.get(:release) do
Pleroma.Config.get(:config_path)
else
if Pleroma.Config.get(:release) do
Pleroma.Config.get(:config_path)
else
"config/#{Pleroma.Config.get(:env)}.secret.exs"
end
"config/#{Pleroma.Config.get(:env)}.secret.exs"
end
do_migrate_to_db(config_file)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment