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