summaryrefslogtreecommitdiff
path: root/priv
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2019-01-15 12:04:54 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2019-01-15 12:04:54 +0300
commitfc965f982c62c43e11cb42c77f7c371c9835a9f2 (patch)
treec74d9f7bb44dd65136f5bd19b849e242af955ef3 /priv
parentdc45ec62c2f5dfcc895854dfbddf6fe9621d3072 (diff)
downloadpleroma-fc965f982c62c43e11cb42c77f7c371c9835a9f2.tar.gz
pleroma-fc965f982c62c43e11cb42c77f7c371c9835a9f2.zip
[#477] Added FTS index for `users`. Fixed failing test.
Diffstat (limited to 'priv')
-rw-r--r--priv/repo/migrations/20190115085500_create_user_fts_index.exs17
1 files changed, 17 insertions, 0 deletions
diff --git a/priv/repo/migrations/20190115085500_create_user_fts_index.exs b/priv/repo/migrations/20190115085500_create_user_fts_index.exs
new file mode 100644
index 000000000..499d67113
--- /dev/null
+++ b/priv/repo/migrations/20190115085500_create_user_fts_index.exs
@@ -0,0 +1,17 @@
+defmodule Pleroma.Repo.Migrations.CreateUserFtsIndex do
+ use Ecto.Migration
+
+ def change do
+ create index(
+ :users,
+ [
+ """
+ (setweight(to_tsvector('simple', regexp_replace(nickname, '\\W', ' ', 'g')), 'A') ||
+ setweight(to_tsvector('simple', regexp_replace(coalesce(name, ''), '\\W', ' ', 'g')), 'B'))
+ """
+ ],
+ name: :users_fts_index,
+ using: :gin
+ )
+ end
+end