logo

pleroma

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

20200328124805_change_following_relationships_state_to_integer.exs (854B)


  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.ChangeFollowingRelationshipsStateToInteger do
  5. use Ecto.Migration
  6. @alter_following_relationship_state "ALTER TABLE following_relationships ALTER COLUMN state"
  7. def up do
  8. execute("""
  9. #{@alter_following_relationship_state} TYPE integer USING
  10. CASE
  11. WHEN state = 'pending' THEN 1
  12. WHEN state = 'accept' THEN 2
  13. WHEN state = 'reject' THEN 3
  14. ELSE 0
  15. END;
  16. """)
  17. end
  18. def down do
  19. execute("""
  20. #{@alter_following_relationship_state} TYPE varchar(255) USING
  21. CASE
  22. WHEN state = 1 THEN 'pending'
  23. WHEN state = 2 THEN 'accept'
  24. WHEN state = 3 THEN 'reject'
  25. ELSE ''
  26. END;
  27. """)
  28. end
  29. end