blob: 3d0e1d5cbdbce40e919ee81d1b9046ee3177cfcc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# Pleroma: A lightweight social networking server
# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Repo.Migrations.AddDefaultsToTables do
use Ecto.Migration
def up do
execute("ALTER TABLE activities
ALTER COLUMN recipients SET DEFAULT ARRAY[]::character varying[]")
execute("ALTER TABLE filters
ALTER COLUMN whole_word SET DEFAULT true")
execute("ALTER TABLE push_subscriptions
ALTER COLUMN data SET DEFAULT '{}'::jsonb")
execute(~s(ALTER TABLE users
ALTER COLUMN tags SET DEFAULT ARRAY[]::character varying[],
ALTER COLUMN notification_settings SET DEFAULT
'{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb))
# irreversible updates
execute(
"UPDATE activities SET recipients = ARRAY[]::character varying[] WHERE recipients IS NULL"
)
execute("UPDATE filters SET whole_word = true WHERE whole_word IS NULL")
execute("UPDATE push_subscriptions SET data = '{}'::jsonb WHERE data IS NULL")
execute("UPDATE users SET source_data = '{}'::jsonb where source_data IS NULL")
execute("UPDATE users SET note_count = 0 where note_count IS NULL")
execute("UPDATE users SET background = '{}'::jsonb where background IS NULL")
execute("UPDATE users SET follower_count = 0 where follower_count IS NULL")
execute(
"UPDATE users SET unread_conversation_count = 0 where unread_conversation_count IS NULL"
)
execute(
~s(UPDATE users SET email_notifications = '{"digest": false}'::jsonb where email_notifications IS NULL)
)
execute("UPDATE users SET default_scope = 'public' where default_scope IS NULL")
execute(
"UPDATE users SET pleroma_settings_store = '{}'::jsonb where pleroma_settings_store IS NULL"
)
execute("UPDATE users SET tags = ARRAY[]::character varying[] WHERE tags IS NULL")
execute(~s(UPDATE users SET notification_settings =
'{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb
WHERE notification_settings = '{}'::jsonb))
end
def down do
execute("ALTER TABLE activities
ALTER COLUMN recipients DROP DEFAULT")
execute("ALTER TABLE filters
ALTER COLUMN whole_word DROP DEFAULT")
execute("ALTER TABLE push_subscriptions
ALTER COLUMN data DROP DEFAULT")
execute("ALTER TABLE users
ALTER COLUMN tags DROP DEFAULT,
ALTER COLUMN notification_settings SET DEFAULT '{}'::jsonb")
end
end
|