summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20171023155035_add_second_object_index_to_activty.exs
blob: f5b0473533a8a06db3e40a1185224f3e41f0b77b (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-2023 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