Update ConfigDB docs for new mix commands

This commit is contained in:
Mark Felder 2020-11-28 11:53:45 -06:00
parent 0847e3e496
commit 570a923a3b

View File

@ -8,17 +8,17 @@ The configuration of Pleroma has traditionally been managed with a config file,
1. Run the mix task to migrate to the database. You'll receive some debugging output and a few messages informing you of what happened. 1. Run the mix task to migrate to the database. You'll receive some debugging output and a few messages informing you of what happened.
**Source:** **Source:**
``` ```
$ mix pleroma.config migrate_to_db $ mix pleroma.config migrate_to_db
``` ```
or or
**OTP:** **OTP:**
*Note: OTP users need Pleroma to be running for `pleroma_ctl` commands to work* *Note: OTP users need Pleroma to be running for `pleroma_ctl` commands to work*
``` ```
$ ./bin/pleroma_ctl config migrate_to_db $ ./bin/pleroma_ctl config migrate_to_db
``` ```
@ -27,28 +27,28 @@ The configuration of Pleroma has traditionally been managed with a config file,
10:04:34.155 [debug] QUERY OK source="config" db=1.6ms decode=2.0ms queue=33.5ms idle=0.0ms 10:04:34.155 [debug] QUERY OK source="config" db=1.6ms decode=2.0ms queue=33.5ms idle=0.0ms
SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_at" FROM "config" AS c0 [] SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_at" FROM "config" AS c0 []
Migrating settings from file: /home/pleroma/config/dev.secret.exs Migrating settings from file: /home/pleroma/config/dev.secret.exs
10:04:34.240 [debug] QUERY OK db=4.5ms queue=0.3ms idle=92.2ms 10:04:34.240 [debug] QUERY OK db=4.5ms queue=0.3ms idle=92.2ms
TRUNCATE config; [] TRUNCATE config; []
10:04:34.244 [debug] QUERY OK db=2.8ms queue=0.3ms idle=97.2ms 10:04:34.244 [debug] QUERY OK db=2.8ms queue=0.3ms idle=97.2ms
ALTER SEQUENCE config_id_seq RESTART; [] ALTER SEQUENCE config_id_seq RESTART; []
10:04:34.256 [debug] QUERY OK source="config" db=0.8ms queue=1.4ms idle=109.8ms 10:04:34.256 [debug] QUERY OK source="config" db=0.8ms queue=1.4ms idle=109.8ms
SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_at" FROM "config" AS c0 WHERE ((c0."group" = $1) AND (c0."key" = $2)) [":pleroma", ":instance"] SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_at" FROM "config" AS c0 WHERE ((c0."group" = $1) AND (c0."key" = $2)) [":pleroma", ":instance"]
10:04:34.292 [debug] QUERY OK db=2.6ms queue=1.7ms idle=137.7ms 10:04:34.292 [debug] QUERY OK db=2.6ms queue=1.7ms idle=137.7ms
INSERT INTO "config" ("group","key","value","inserted_at","updated_at") VALUES ($1,$2,$3,$4,$5) RETURNING "id" [":pleroma", ":instance", <<131, 108, 0, 0, 0, 1, 104, 2, 100, 0, 4, 110, 97, 109, 101, 109, 0, 0, 0, 7, 66, 108, 101, 114, 111, 109, 97, 106>>, ~N[2020-07-12 15:04:34], ~N[2020-07-12 15:04:34]] INSERT INTO "config" ("group","key","value","inserted_at","updated_at") VALUES ($1,$2,$3,$4,$5) RETURNING "id" [":pleroma", ":instance", <<131, 108, 0, 0, 0, 1, 104, 2, 100, 0, 4, 110, 97, 109, 101, 109, 0, 0, 0, 7, 66, 108, 101, 114, 111, 109, 97, 106>>, ~N[2020-07-12 15:04:34], ~N[2020-07-12 15:04:34]]
Settings for key instance migrated. Settings for key instance migrated.
Settings for group :pleroma migrated. Settings for group :pleroma migrated.
``` ```
2. It is recommended to backup your config file now. 2. It is recommended to backup your config file now.
``` ```
cp config/dev.secret.exs config/dev.secret.exs.orig cp config/dev.secret.exs config/dev.secret.exs.orig
``` ```
3. Edit your Pleroma config to enable database configuration: 3. Edit your Pleroma config to enable database configuration:
``` ```
@ -76,17 +76,17 @@ The configuration of Pleroma has traditionally been managed with a config file,
config :pleroma, Pleroma.Web.Endpoint, config :pleroma, Pleroma.Web.Endpoint,
url: [host: "cool.pleroma.site", scheme: "https", port: 443] url: [host: "cool.pleroma.site", scheme: "https", port: 443]
config :pleroma, Pleroma.Repo, config :pleroma, Pleroma.Repo,
adapter: Ecto.Adapters.Postgres, adapter: Ecto.Adapters.Postgres,
username: "pleroma", username: "pleroma",
password: "MySecretPassword", password: "MySecretPassword",
database: "pleroma_prod", database: "pleroma_prod",
hostname: "localhost" hostname: "localhost"
config :pleroma, configurable_from_database: true config :pleroma, configurable_from_database: true
``` ```
5. Restart your instance and you can now access the Settings tab in AdminFE. 5. Restart your instance and you can now access the Settings tab in AdminFE.
@ -95,15 +95,15 @@ The configuration of Pleroma has traditionally been managed with a config file,
1. Run the mix task to migrate back from the database. You'll receive some debugging output and a few messages informing you of what happened. 1. Run the mix task to migrate back from the database. You'll receive some debugging output and a few messages informing you of what happened.
**Source:** **Source:**
``` ```
$ mix pleroma.config migrate_from_db $ mix pleroma.config migrate_from_db
``` ```
or or
**OTP:** **OTP:**
``` ```
$ ./bin/pleroma_ctl config migrate_from_db $ ./bin/pleroma_ctl config migrate_from_db
``` ```
@ -111,7 +111,7 @@ The configuration of Pleroma has traditionally been managed with a config file,
``` ```
10:26:30.593 [debug] QUERY OK source="config" db=9.8ms decode=1.2ms queue=26.0ms idle=0.0ms 10:26:30.593 [debug] QUERY OK source="config" db=9.8ms decode=1.2ms queue=26.0ms idle=0.0ms
SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_at" FROM "config" AS c0 [] SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_at" FROM "config" AS c0 []
10:26:30.659 [debug] QUERY OK source="config" db=1.1ms idle=80.7ms 10:26:30.659 [debug] QUERY OK source="config" db=1.1ms idle=80.7ms
SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_at" FROM "config" AS c0 [] SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_at" FROM "config" AS c0 []
Database configuration settings have been saved to config/dev.exported_from_db.secret.exs Database configuration settings have been saved to config/dev.exported_from_db.secret.exs
@ -124,40 +124,45 @@ The configuration of Pleroma has traditionally been managed with a config file,
## Debugging ## Debugging
### Clearing database config ### Clearing database config
You can clear the database config by truncating the `config` table in the database. e.g., You can clear the database config with the following command:
``` **Source:**
psql -d pleroma_dev
pleroma_dev=# TRUNCATE config; ```
TRUNCATE TABLE $ mix pleroma.config reset
``` ```
or
**OTP:**
```
$ ./bin/pleroma_ctl config reset
```
Additionally, every time you migrate the configuration to the database the config table is automatically truncated to ensure a clean migration. Additionally, every time you migrate the configuration to the database the config table is automatically truncated to ensure a clean migration.
### Manually removing a setting ### Manually removing a setting
If you encounter a situation where the server cannot run properly because of an invalid setting in the database and this is preventing you from accessing AdminFE, you can manually remove the offending setting if you know which one it is. If you encounter a situation where the server cannot run properly because of an invalid setting in the database and this is preventing you from accessing AdminFE, you can manually remove the offending setting if you know which one it is.
e.g., here is an example showing a minimal configuration in the database. Only the `config :pleroma, :instance` settings are in the table: e.g., here is an example showing a the removal of the `config :pleroma, :instance` settings:
``` **Source:**
$ mix pleroma.config keylist
The following configuration keys are set in ConfigDB:
- instance ```
$ mix pleroma.config delete pleroma instance
Are you sure you want to continue? [n] y
config :pleroma, :instance deleted from the ConfigDB.
```
``` or
``` **OTP:**
$ mix pleroma.config show instance
config :pleroma, :instance, [name: "MyPleroma", description: "A fun place to hang out!", notify_email: "no-reply@mypleroma.com", email: "admin@mypleroma.com", account_activation_required: true]
``` ```
$ ./bin/pleroma_ctl config delete pleroma instance
To delete the saved settings for `:instance`: Are you sure you want to continue? [n] y
config :pleroma, :instance deleted from the ConfigDB.
``` ```
$ mix pleroma.config keydel instance
instance deleted from the ConfigDB.
```
Now the `config :pleroma, :instance` settings have been removed from the database. Now the `config :pleroma, :instance` settings have been removed from the database.