Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

69 Zeilen
2.3KB

  1. defmodule Pleroma.Repo.Migrations.AddDefaultsToTables do
  2. use Ecto.Migration
  3. def up do
  4. execute("ALTER TABLE activities
  5. ALTER COLUMN recipients SET DEFAULT ARRAY[]::character varying[]")
  6. execute("ALTER TABLE filters
  7. ALTER COLUMN whole_word SET DEFAULT true")
  8. execute("ALTER TABLE push_subscriptions
  9. ALTER COLUMN data SET DEFAULT '{}'::jsonb")
  10. execute(~s(ALTER TABLE users
  11. ALTER COLUMN tags SET DEFAULT ARRAY[]::character varying[],
  12. ALTER COLUMN notification_settings SET DEFAULT
  13. '{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb))
  14. # irreversible updates
  15. execute(
  16. "UPDATE activities SET recipients = ARRAY[]::character varying[] WHERE recipients IS NULL"
  17. )
  18. execute("UPDATE filters SET whole_word = true WHERE whole_word IS NULL")
  19. execute("UPDATE push_subscriptions SET data = '{}'::jsonb WHERE data IS NULL")
  20. execute("UPDATE users SET source_data = '{}'::jsonb where source_data IS NULL")
  21. execute("UPDATE users SET note_count = 0 where note_count IS NULL")
  22. execute("UPDATE users SET background = '{}'::jsonb where background IS NULL")
  23. execute("UPDATE users SET follower_count = 0 where follower_count IS NULL")
  24. execute(
  25. "UPDATE users SET unread_conversation_count = 0 where unread_conversation_count IS NULL"
  26. )
  27. execute(
  28. ~s(UPDATE users SET email_notifications = '{"digest": false}'::jsonb where email_notifications IS NULL)
  29. )
  30. execute("UPDATE users SET default_scope = 'public' where default_scope IS NULL")
  31. execute(
  32. "UPDATE users SET pleroma_settings_store = '{}'::jsonb where pleroma_settings_store IS NULL"
  33. )
  34. execute("UPDATE users SET tags = ARRAY[]::character varying[] WHERE tags IS NULL")
  35. execute(~s(UPDATE users SET notification_settings =
  36. '{"followers": true, "follows": true, "non_follows": true, "non_followers": true}'::jsonb
  37. WHERE notification_settings = '{}'::jsonb))
  38. end
  39. def down do
  40. execute("ALTER TABLE activities
  41. ALTER COLUMN recipients DROP DEFAULT")
  42. execute("ALTER TABLE filters
  43. ALTER COLUMN whole_word DROP DEFAULT")
  44. execute("ALTER TABLE push_subscriptions
  45. ALTER COLUMN data DROP DEFAULT")
  46. execute("ALTER TABLE users
  47. ALTER COLUMN tags DROP DEFAULT,
  48. ALTER COLUMN notification_settings SET DEFAULT '{}'::jsonb")
  49. end
  50. end