akkoma/priv/repo/optional_migrations/pgroonga/20230802195431_create_pgroonga_index.exs

29 lines
685 B
Elixir

defmodule Pleroma.Repo.Migrations.CreatePgroongaIndex do
use Ecto.Migration
def up do
execute("DROP INDEX IF EXISTS objects_fts")
execute("CREATE EXTENSION IF NOT EXISTS pgroonga")
create_if_not_exists(
index(:objects, ["(data->'content') pgroonga_jsonb_full_text_search_ops_v2"],
using: :pgroonga,
name: :object_content_pgroonga
)
)
end
def down do
execute("DROP INDEX IF EXISTS object_content_pgroonga")
execute("DROP EXTENSION IF EXISTS pgroonga")
create_if_not_exists(
index(:objects, ["(to_tsvector('english', data->>'content'))"],
using: :gin,
name: :objects_fts
)
)
end
end