logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

20191026191910_set_not_null_for_users.exs (1725B)


  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. defmodule Pleroma.Repo.Migrations.SetNotNullForUsers do
  5. use Ecto.Migration
  6. # modify/3 function will require index recreation, so using execute/1 instead
  7. def up do
  8. # irreversible
  9. execute("UPDATE users SET follower_count = 0 WHERE follower_count IS NULL")
  10. execute("ALTER TABLE users
  11. ALTER COLUMN local SET NOT NULL,
  12. ALTER COLUMN source_data SET NOT NULL,
  13. ALTER COLUMN note_count SET NOT NULL,
  14. ALTER COLUMN follower_count SET NOT NULL,
  15. ALTER COLUMN blocks SET NOT NULL,
  16. ALTER COLUMN domain_blocks SET NOT NULL,
  17. ALTER COLUMN mutes SET NOT NULL,
  18. ALTER COLUMN muted_reblogs SET NOT NULL,
  19. ALTER COLUMN muted_notifications SET NOT NULL,
  20. ALTER COLUMN subscribers SET NOT NULL,
  21. ALTER COLUMN pinned_activities SET NOT NULL,
  22. ALTER COLUMN emoji SET NOT NULL,
  23. ALTER COLUMN fields SET NOT NULL,
  24. ALTER COLUMN raw_fields SET NOT NULL")
  25. end
  26. def down do
  27. execute("ALTER TABLE users
  28. ALTER COLUMN local DROP NOT NULL,
  29. ALTER COLUMN source_data DROP NOT NULL,
  30. ALTER COLUMN note_count DROP NOT NULL,
  31. ALTER COLUMN follower_count DROP NOT NULL,
  32. ALTER COLUMN blocks DROP NOT NULL,
  33. ALTER COLUMN domain_blocks DROP NOT NULL,
  34. ALTER COLUMN mutes DROP NOT NULL,
  35. ALTER COLUMN muted_reblogs DROP NOT NULL,
  36. ALTER COLUMN muted_notifications DROP NOT NULL,
  37. ALTER COLUMN subscribers DROP NOT NULL,
  38. ALTER COLUMN pinned_activities DROP NOT NULL,
  39. ALTER COLUMN emoji DROP NOT NULL,
  40. ALTER COLUMN fields DROP NOT NULL,
  41. ALTER COLUMN raw_fields DROP NOT NULL")
  42. end
  43. end