ac891499320e0c76757d7662b75965dd036b103e
[anni] / priv / repo / migrations / 20200606105430_change_type_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.ChangeTypeToEnumForNotifications do
6   use Ecto.Migration
7
8   def up do
9     """
10     create type notification_type as enum (
11       'follow',
12       'follow_request',
13       'mention',
14       'move',
15       'pleroma:emoji_reaction',
16       'pleroma:chat_mention',
17       'reblog',
18       'favourite'
19     )
20     """
21     |> execute()
22
23     """
24     alter table notifications 
25     alter column type type notification_type using (type::notification_type)
26     """
27     |> execute()
28   end
29
30   def down do
31     alter table(:notifications) do
32       modify(:type, :string)
33     end
34
35     """
36     drop type notification_type
37     """
38     |> execute()
39   end
40 end