summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20200914105800_add_notification_constraints.exs
blob: d2f88bc621d17f928932121c7b3acccff26f07b9 (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
# 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.AddNotificationConstraints do
  use Ecto.Migration

  def up do
    drop(constraint(:notifications, "notifications_activity_id_fkey"))

    alter table(:notifications) do
      modify(:activity_id, references(:activities, type: :uuid, on_delete: :delete_all),
        null: false
      )
    end
  end

  def down do
    drop(constraint(:notifications, "notifications_activity_id_fkey"))

    alter table(:notifications) do
      modify(:activity_id, references(:activities, type: :uuid, on_delete: :delete_all),
        null: true
      )
    end
  end
end