Merge branch 'fixes_2034_reports_should_send_a_notification_to_admins' into 'develop'
[akkoma] / priv / repo / migrations / 20200831152600_add_pleroma_report_to_enum_for_notifications.exs
1 defmodule Pleroma.Repo.Migrations.AddPleromaReportTypeToEnumForNotifications do
2 use Ecto.Migration
3
4 @disable_ddl_transaction true
5
6 def up do
7 """
8 alter type notification_type add value 'pleroma:report'
9 """
10 |> execute()
11 end
12
13 def down do
14 alter table(:notifications) do
15 modify(:type, :string)
16 end
17
18 """
19 delete from notifications where type = 'pleroma:report'
20 """
21 |> execute()
22
23 """
24 drop type if exists notification_type
25 """
26 |> execute()
27
28 """
29 create type notification_type as enum (
30 'follow',
31 'follow_request',
32 'mention',
33 'move',
34 'pleroma:emoji_reaction',
35 'pleroma:chat_mention',
36 'reblog',
37 'favourite'
38 )
39 """
40 |> execute()
41
42 """
43 alter table notifications
44 alter column type type notification_type using (type::notification_type)
45 """
46 |> execute()
47 end
48 end