summaryrefslogtreecommitdiff
path: root/priv/repo
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2020-10-12 17:42:27 -0500
committerMark Felder <feld@feld.me>2021-01-15 11:24:46 -0600
commit860b5c78048ede3597a02b6029634d74fd520204 (patch)
treea9268819d41ae978c17d4bdfbb80c936301b094d /priv/repo
parentcf367fdbd53b50f4324a01ddabdc0520cd787321 (diff)
downloadpleroma-860b5c78048ede3597a02b6029634d74fd520204.tar.gz
pleroma-860b5c78048ede3597a02b6029634d74fd520204.zip
Change user.deactivated field to user.is_active
Diffstat (limited to 'priv/repo')
-rw-r--r--priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs18
1 files changed, 18 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..ac0afdd16
--- /dev/null
+++ b/priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs
@@ -0,0 +1,18 @@
+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