move to 2.5.5
[anni] / priv / repo / migrations / 20210717000000_add_poll_to_notifications_enum.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.AddPollToNotificationsEnum do
6   use Ecto.Migration
7
8   @disable_ddl_transaction true
9
10   def up do
11     """
12     alter type notification_type add value 'poll'
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 = 'poll'
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       'pleroma:report'
43     )
44     """
45     |> execute()
46
47     """
48     alter table notifications
49     alter column type type notification_type using (type::notification_type)
50     """
51     |> execute()
52   end
53 end