fixed migration the settings to DB

This commit is contained in:
Maksim Pechnikov 2020-06-17 09:15:35 +03:00
parent bb68f9d27c
commit 02a5648feb
3 changed files with 20 additions and 15 deletions

View file

@ -52,6 +52,7 @@ defmodule Mix.Tasks.Pleroma.Config do
defp do_migrate_to_db(config_file) do defp do_migrate_to_db(config_file) do
if File.exists?(config_file) do if File.exists?(config_file) do
shell_info("Running migrate settings from file: #{Path.expand(config_file)}")
Ecto.Adapters.SQL.query!(Repo, "TRUNCATE config;") Ecto.Adapters.SQL.query!(Repo, "TRUNCATE config;")
Ecto.Adapters.SQL.query!(Repo, "ALTER SEQUENCE config_id_seq RESTART;") Ecto.Adapters.SQL.query!(Repo, "ALTER SEQUENCE config_id_seq RESTART;")

View file

@ -8,7 +8,6 @@ defmodule Pleroma.Config.Loader do
Pleroma.Web.Endpoint, Pleroma.Web.Endpoint,
:env, :env,
:configurable_from_database, :configurable_from_database,
:database,
:swarm :swarm
] ]

View file

@ -2,6 +2,7 @@ defmodule Pleroma.Repo.Migrations.AddFtsIndexToObjectsTwo do
use Ecto.Migration use Ecto.Migration
def up do def up do
if Pleroma.Config.get([:database, :rum_enabled]) do
execute("create extension if not exists rum") execute("create extension if not exists rum")
drop_if_exists index(:objects, ["(to_tsvector('english', data->>'content'))"], using: :gin, name: :objects_fts) drop_if_exists index(:objects, ["(to_tsvector('english', data->>'content'))"], using: :gin, name: :objects_fts)
alter table(:objects) do alter table(:objects) do
@ -20,6 +21,10 @@ defmodule Pleroma.Repo.Migrations.AddFtsIndexToObjectsTwo do
FOR EACH ROW EXECUTE PROCEDURE objects_fts_update()") FOR EACH ROW EXECUTE PROCEDURE objects_fts_update()")
execute("UPDATE objects SET updated_at = NOW()") execute("UPDATE objects SET updated_at = NOW()")
else
raise Ecto.MigrationError,
message: "Migration is not allowed. You can change this behavior by setting `database/rum_enabled` to true."
end
end end
def down do def down do