Merge pull request 'Manually define PATH for Arch Linux users in systemd unit' (...
[akkoma] / priv / repo / migrations / 20210717000000_add_poll_to_notifications_enum.exs
1 defmodule Pleroma.Repo.Migrations.AddPollToNotificationsEnum do
2 use Ecto.Migration
3
4 @disable_ddl_transaction true
5
6 def up do
7 """
8 alter type notification_type add value 'poll'
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 = 'poll'
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 'pleroma:report'
39 )
40 """
41 |> execute()
42
43 """
44 alter table notifications
45 alter column type type notification_type using (type::notification_type)
46 """
47 |> execute()
48 end
49 end