mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-19 03:19:17 +00:00
truncate config table on migrate to db task
This commit is contained in:
parent
dddebee047
commit
4344c5d5b9
|
@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Store status data inside Flag activity
|
||||
- Deprecated (reorganized as `UserRelationship` entity) User fields with user AP IDs (`blocks`, `mutes`, `muted_reblogs`, `muted_notifications`, `subscribers`).
|
||||
- Logger: default log level changed from `warn` to `info`.
|
||||
- Config mix task `migrate_to_db` truncates `config` table before migrating the config file.
|
||||
<details>
|
||||
<summary>API Changes</summary>
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ def migrate_to_db(file_path \\ nil) do
|
|||
|
||||
defp do_migrate_to_db(config_file) do
|
||||
if File.exists?(config_file) do
|
||||
Ecto.Adapters.SQL.query!(Repo, "TRUNCATE config;")
|
||||
|
||||
custom_config =
|
||||
config_file
|
||||
|> read_file()
|
||||
|
|
|
@ -34,9 +34,13 @@ test "error if file with custom settings doesn't exist" do
|
|||
15
|
||||
end
|
||||
|
||||
test "settings are migrated to db" do
|
||||
describe "migrate_to_db/1" do
|
||||
setup do
|
||||
initial = Application.get_env(:quack, :level)
|
||||
on_exit(fn -> Application.put_env(:quack, :level, initial) end)
|
||||
end
|
||||
|
||||
test "settings are migrated to db" do
|
||||
assert Repo.all(ConfigDB) == []
|
||||
|
||||
Mix.Tasks.Pleroma.Config.migrate_to_db("test/fixtures/config/temp.secret.exs")
|
||||
|
@ -51,6 +55,22 @@ test "settings are migrated to db" do
|
|||
assert ConfigDB.from_binary(config3.value) == :info
|
||||
end
|
||||
|
||||
test "config table is truncated before migration" do
|
||||
ConfigDB.create(%{
|
||||
group: ":pleroma",
|
||||
key: ":first_setting",
|
||||
value: [key: "value", key2: ["Activity"]]
|
||||
})
|
||||
|
||||
assert Repo.aggregate(ConfigDB, :count, :id) == 1
|
||||
|
||||
Mix.Tasks.Pleroma.Config.migrate_to_db("test/fixtures/config/temp.secret.exs")
|
||||
|
||||
config = ConfigDB.get_by_params(%{group: ":pleroma", key: ":first_setting"})
|
||||
assert ConfigDB.from_binary(config.value) == [key: "value", key2: [Repo]]
|
||||
end
|
||||
end
|
||||
|
||||
describe "with deletion temp file" do
|
||||
setup do
|
||||
temp_file = "config/temp.exported_from_db.secret.exs"
|
||||
|
|
Loading…
Reference in a new issue