First
[anni] / priv / repo / migrations / 20190115085500_create_user_fts_index.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Repo.Migrations.CreateUserFtsIndex do
6   use Ecto.Migration
7
8   def change do
9     create_if_not_exists(
10       index(
11         :users,
12         [
13           """
14           (setweight(to_tsvector('simple', regexp_replace(nickname, '\\W', ' ', 'g')), 'A') ||
15           setweight(to_tsvector('simple', regexp_replace(coalesce(name, ''), '\\W', ' ', 'g')), 'B'))
16           """
17         ],
18         name: :users_fts_index,
19         using: :gin
20       )
21     )
22   end
23 end