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

  def up do
    execute("ALTER TABLE hashtags_objects DROP CONSTRAINT hashtags_objects_object_id_fkey")

    alter table(:hashtags_objects) do
      modify(:object_id, references(:objects, on_delete: :delete_all))
    end
  end

  def down do
    execute("ALTER TABLE hashtags_objects DROP CONSTRAINT hashtags_objects_object_id_fkey")

    alter table(:hashtags_objects) do
      modify(:object_id, references(:objects, on_delete: :nothing))
    end
  end
end