logo

pleroma

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

20201012173004_refactor_deactivated_user_field.exs (942B)


  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.RefactorDeactivatedUserField do
  5. use Ecto.Migration
  6. def up do
  7. # Flip the values before we change the meaning of the column
  8. execute("UPDATE users SET deactivated = NOT deactivated;")
  9. execute("ALTER TABLE users RENAME COLUMN deactivated TO is_active;")
  10. execute("ALTER TABLE users ALTER COLUMN is_active SET DEFAULT true;")
  11. execute("ALTER INDEX users_deactivated_index RENAME TO users_is_active_index;")
  12. end
  13. def down do
  14. execute("UPDATE users SET is_active = NOT is_active;")
  15. execute("ALTER TABLE users RENAME COLUMN is_active TO deactivated;")
  16. execute("ALTER TABLE users ALTER COLUMN deactivated SET DEFAULT false;")
  17. execute("ALTER INDEX users_is_active_index RENAME TO users_deactivated_index;")
  18. end
  19. end