summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20170501133231_add_id_contraints_to_activities_and_objects_part_two.exs
blob: d83ea881eaa5d588fee411c82386bce61fe28190 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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.AddIdContraintsToActivitiesAndObjectsPartTwo do
  use Ecto.Migration

  def up do
    drop_if_exists(index(:objects, ["(data->>\"id\")"], name: :objects_unique_apid_index))
    drop_if_exists(index(:activities, ["(data->>\"id\")"], name: :activities_unique_apid_index))

    create_if_not_exists(
      unique_index(:objects, ["(data->>'id')"], name: :objects_unique_apid_index)
    )

    create_if_not_exists(
      unique_index(:activities, ["(data->>'id')"], name: :activities_unique_apid_index)
    )
  end

  def down, do: :ok
end