1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Repo.Migrations.AddDefaultsToTables do
9 execute("ALTER TABLE activities
10 ALTER COLUMN recipients SET DEFAULT ARRAY[]::character varying[]")
12 execute("ALTER TABLE filters
13 ALTER COLUMN whole_word SET DEFAULT true")
15 execute("ALTER TABLE push_subscriptions
16 ALTER COLUMN data SET DEFAULT '{}'::jsonb")
18 execute(~s(ALTER TABLE users
19 ALTER COLUMN tags SET DEFAULT ARRAY[]::character varying[],
20 ALTER COLUMN notification_settings SET DEFAULT
21 '{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb))
23 # irreversible updates
26 "UPDATE activities SET recipients = ARRAY[]::character varying[] WHERE recipients IS NULL"
29 execute("UPDATE filters SET whole_word = true WHERE whole_word IS NULL")
31 execute("UPDATE push_subscriptions SET data = '{}'::jsonb WHERE data IS NULL")
33 execute("UPDATE users SET source_data = '{}'::jsonb where source_data IS NULL")
34 execute("UPDATE users SET note_count = 0 where note_count IS NULL")
35 execute("UPDATE users SET background = '{}'::jsonb where background IS NULL")
36 execute("UPDATE users SET follower_count = 0 where follower_count IS NULL")
39 "UPDATE users SET unread_conversation_count = 0 where unread_conversation_count IS NULL"
43 ~s(UPDATE users SET email_notifications = '{"digest": false}'::jsonb where email_notifications IS NULL)
46 execute("UPDATE users SET default_scope = 'public' where default_scope IS NULL")
49 "UPDATE users SET pleroma_settings_store = '{}'::jsonb where pleroma_settings_store IS NULL"
52 execute("UPDATE users SET tags = ARRAY[]::character varying[] WHERE tags IS NULL")
53 execute(~s(UPDATE users SET notification_settings =
54 '{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb
55 WHERE notification_settings = '{}'::jsonb))
59 execute("ALTER TABLE activities
60 ALTER COLUMN recipients DROP DEFAULT")
62 execute("ALTER TABLE filters
63 ALTER COLUMN whole_word DROP DEFAULT")
65 execute("ALTER TABLE push_subscriptions
66 ALTER COLUMN data DROP DEFAULT")
68 execute("ALTER TABLE users
69 ALTER COLUMN tags DROP DEFAULT,
70 ALTER COLUMN notification_settings SET DEFAULT '{}'::jsonb")