diff options
| author | feld <feld@feld.me> | 2021-01-25 16:54:57 +0000 | 
|---|---|---|
| committer | feld <feld@feld.me> | 2021-01-25 16:54:57 +0000 | 
| commit | f1c82fbd426651e6838a9c60578c96a25ae94df4 (patch) | |
| tree | 9b6933bcfaea56aadf855c59f7783b73f6e5fff8 /priv/repo/migrations | |
| parent | 0a6f5f479348eff5f5404d4455fcb8254809812f (diff) | |
| parent | f868dcf3acc0fd687a4a74e74f6e150ef565f787 (diff) | |
| download | pleroma-f1c82fbd426651e6838a9c60578c96a25ae94df4.tar.gz pleroma-f1c82fbd426651e6838a9c60578c96a25ae94df4.zip | |
Merge branch 'refactor/deactivated_user_field' into 'develop'
Change user.deactivated field to user.is_active
See merge request pleroma/pleroma!3073
Diffstat (limited to 'priv/repo/migrations')
| -rw-r--r-- | priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs | 22 | 
1 files changed, 22 insertions, 0 deletions
| diff --git a/priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs b/priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs new file mode 100644 index 000000000..58b75b436 --- /dev/null +++ b/priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs @@ -0,0 +1,22 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Repo.Migrations.RefactorDeactivatedUserField do +  use Ecto.Migration + +  def up do +    # Flip the values before we change the meaning of the column +    execute("UPDATE users SET deactivated = NOT deactivated;") +    execute("ALTER TABLE users RENAME COLUMN deactivated TO is_active;") +    execute("ALTER TABLE users ALTER COLUMN is_active SET DEFAULT true;") +    execute("ALTER INDEX users_deactivated_index RENAME TO users_is_active_index;") +  end + +  def down do +    execute("UPDATE users SET is_active = NOT is_active;") +    execute("ALTER TABLE users RENAME COLUMN is_active TO deactivated;") +    execute("ALTER TABLE users ALTER COLUMN deactivated SET DEFAULT false;") +    execute("ALTER INDEX users_is_active_index RENAME TO users_deactivated_index;") +  end +end | 
