summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20171023155035_add_second_object_index_to_activty.exs
blob: 0bbdd8ccf93d7f2d39d7ce92f941d601283906e3 (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
# 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.AddSecondObjectIndexToActivty do
  use Ecto.Migration

  @disable_ddl_transaction true

  def change do
    drop_if_exists(
      index(:activities, ["(data->'object'->>'id')", "(data->>'type')"],
        name: :activities_create_objects_index
      )
    )

    create(
      index(:activities, ["(coalesce(data->'object'->>'id', data->>'object'))"],
        name: :activities_create_objects_index,
        concurrently: true
      )
    )
  end
end