Add option to modify HTTP pool size
[akkoma] / priv / repo / migrations / 20191025143434_add_defaults_to_tables.exs
1 defmodule Pleroma.Repo.Migrations.AddDefaultsToTables do
2 use Ecto.Migration
3
4 def up do
5 execute("ALTER TABLE activities
6 ALTER COLUMN recipients SET DEFAULT ARRAY[]::character varying[]")
7
8 execute("ALTER TABLE filters
9 ALTER COLUMN whole_word SET DEFAULT true")
10
11 execute("ALTER TABLE push_subscriptions
12 ALTER COLUMN data SET DEFAULT '{}'::jsonb")
13
14 execute(~s(ALTER TABLE users
15 ALTER COLUMN tags SET DEFAULT ARRAY[]::character varying[],
16 ALTER COLUMN notification_settings SET DEFAULT
17 '{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb))
18
19 # irreversible updates
20
21 execute(
22 "UPDATE activities SET recipients = ARRAY[]::character varying[] WHERE recipients IS NULL"
23 )
24
25 execute("UPDATE filters SET whole_word = true WHERE whole_word IS NULL")
26
27 execute("UPDATE push_subscriptions SET data = '{}'::jsonb WHERE data IS NULL")
28
29 execute("UPDATE users SET source_data = '{}'::jsonb where source_data IS NULL")
30 execute("UPDATE users SET note_count = 0 where note_count IS NULL")
31 execute("UPDATE users SET background = '{}'::jsonb where background IS NULL")
32 execute("UPDATE users SET follower_count = 0 where follower_count IS NULL")
33
34 execute(
35 "UPDATE users SET unread_conversation_count = 0 where unread_conversation_count IS NULL"
36 )
37
38 execute(
39 ~s(UPDATE users SET email_notifications = '{"digest": false}'::jsonb where email_notifications IS NULL)
40 )
41
42 execute("UPDATE users SET default_scope = 'public' where default_scope IS NULL")
43
44 execute(
45 "UPDATE users SET pleroma_settings_store = '{}'::jsonb where pleroma_settings_store IS NULL"
46 )
47
48 execute("UPDATE users SET tags = ARRAY[]::character varying[] WHERE tags IS NULL")
49 execute(~s(UPDATE users SET notification_settings =
50 '{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb
51 WHERE notification_settings = '{}'::jsonb))
52 end
53
54 def down do
55 execute("ALTER TABLE activities
56 ALTER COLUMN recipients DROP DEFAULT")
57
58 execute("ALTER TABLE filters
59 ALTER COLUMN whole_word DROP DEFAULT")
60
61 execute("ALTER TABLE push_subscriptions
62 ALTER COLUMN data DROP DEFAULT")
63
64 execute("ALTER TABLE users
65 ALTER COLUMN tags DROP DEFAULT,
66 ALTER COLUMN notification_settings SET DEFAULT '{}'::jsonb")
67 end
68 end