summaryrefslogtreecommitdiff
path: root/priv/repo/optional_migrations
diff options
context:
space:
mode:
authorMaksim Pechnikov <parallel588@gmail.com>2020-06-22 17:27:49 +0300
committerMaksim Pechnikov <parallel588@gmail.com>2020-06-22 17:27:49 +0300
commitb0a40fc2e42a186fc6bb383621f291411b2a81be (patch)
treefce99c2c55184d41b33f21585a3ed4789136fc22 /priv/repo/optional_migrations
parent4cb7b1ebc6b255faae635f6138bf90264e84e1fb (diff)
downloadpleroma-b0a40fc2e42a186fc6bb383621f291411b2a81be.tar.gz
pleroma-b0a40fc2e42a186fc6bb383621f291411b2a81be.zip
added verify RUM settings before start app
Diffstat (limited to 'priv/repo/optional_migrations')
-rw-r--r--priv/repo/optional_migrations/rum_indexing/20190510135645_add_fts_index_to_objects_two.exs35
1 files changed, 15 insertions, 20 deletions
diff --git a/priv/repo/optional_migrations/rum_indexing/20190510135645_add_fts_index_to_objects_two.exs b/priv/repo/optional_migrations/rum_indexing/20190510135645_add_fts_index_to_objects_two.exs
index 79bde163d..757afa129 100644
--- a/priv/repo/optional_migrations/rum_indexing/20190510135645_add_fts_index_to_objects_two.exs
+++ b/priv/repo/optional_migrations/rum_indexing/20190510135645_add_fts_index_to_objects_two.exs
@@ -2,29 +2,24 @@ defmodule Pleroma.Repo.Migrations.AddFtsIndexToObjectsTwo do
use Ecto.Migration
def up do
- if Pleroma.Config.get([:database, :rum_enabled]) do
- execute("create extension if not exists rum")
- drop_if_exists index(:objects, ["(to_tsvector('english', data->>'content'))"], using: :gin, name: :objects_fts)
- alter table(:objects) do
- add(:fts_content, :tsvector)
- end
+ execute("create extension if not exists rum")
+ drop_if_exists index(:objects, ["(to_tsvector('english', data->>'content'))"], using: :gin, name: :objects_fts)
+ alter table(:objects) do
+ add(:fts_content, :tsvector)
+ end
- execute("CREATE FUNCTION objects_fts_update() RETURNS trigger AS $$
- begin
- new.fts_content := to_tsvector('english', new.data->>'content');
- return new;
- end
- $$ LANGUAGE plpgsql")
- execute("create index if not exists objects_fts on objects using RUM (fts_content rum_tsvector_addon_ops, inserted_at) with (attach = 'inserted_at', to = 'fts_content');")
+ execute("CREATE FUNCTION objects_fts_update() RETURNS trigger AS $$
+ begin
+ new.fts_content := to_tsvector('english', new.data->>'content');
+ return new;
+ end
+ $$ LANGUAGE plpgsql")
+ execute("create index if not exists objects_fts on objects using RUM (fts_content rum_tsvector_addon_ops, inserted_at) with (attach = 'inserted_at', to = 'fts_content');")
- execute("CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON objects
- FOR EACH ROW EXECUTE PROCEDURE objects_fts_update()")
+ execute("CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON objects
+ FOR EACH ROW EXECUTE PROCEDURE objects_fts_update()")
- 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
+ execute("UPDATE objects SET updated_at = NOW()")
end
def down do