3c1b16badb254fa7fd755a5ac7dcdeec52a005c1
[anni] / priv / repo / migrations / 20200831152600_add_pleroma_report_to_enum_for_notifications.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Repo.Migrations.AddPleromaReportTypeToEnumForNotifications do
6   use Ecto.Migration
7
8   @disable_ddl_transaction true
9
10   def up do
11     """
12     alter type notification_type add value 'pleroma:report'
13     """
14     |> execute()
15   end
16
17   def down do
18     alter table(:notifications) do
19       modify(:type, :string)
20     end
21
22     """
23     delete from notifications where type = 'pleroma:report'
24     """
25     |> execute()
26
27     """
28     drop type if exists notification_type
29     """
30     |> execute()
31
32     """
33     create type notification_type as enum (
34       'follow',
35       'follow_request',
36       'mention',
37       'move',
38       'pleroma:emoji_reaction',
39       'pleroma:chat_mention',
40       'reblog',
41       'favourite'
42     )
43     """
44     |> execute()
45
46     """
47     alter table notifications 
48     alter column type type notification_type using (type::notification_type)
49     """
50     |> execute()
51   end
52 end