summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20190204200237_add_correct_dm_index.exs
blob: a9beb97e04d63c4f8a74b274cfa4e5cc75c84c29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Repo.Migrations.AddCorrectDMIndex do
  use Ecto.Migration
  @disable_ddl_transaction true

  def up do
    drop_if_exists(
      index(:activities, ["activity_visibility(actor, recipients, data)"],
        name: :activities_visibility_index
      )
    )

    create(
      index(:activities, ["activity_visibility(actor, recipients, data)", "id DESC NULLS LAST"],
        name: :activities_visibility_index,
        concurrently: true,
        where: "data->>'type' = 'Create'"
      )
    )
  end

  def down do
    drop_if_exists(
      index(:activities, ["activity_visibility(actor, recipients, data)", "id DESC"],
        name: :activities_visibility_index,
        concurrently: true,
        where: "data->>'type' = 'Create'"
      )
    )
  end
end