First
[anni] / priv / repo / migrations / 20210401143153_user_notification_settings_fix.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.UserNotificationSettingsFix do
6   use Ecto.Migration
7
8   def up do
9     execute(~s(UPDATE users
10     SET 
11       notification_settings = '{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb WHERE notification_settings IS NULL
12 ))
13
14     execute("ALTER TABLE users
15     ALTER COLUMN notification_settings SET NOT NULL")
16   end
17
18   def down do
19     :ok
20   end
21 end