922d75430dc4091f30a48a8ff8bedeeaaf08fd6c
[anni] / priv / repo / migrations / 20201013184200_refactor_confirmation_pending_user_field.exs
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
5 defmodule Pleroma.Repo.Migrations.RefactorConfirmationPendingUserField do
6   use Ecto.Migration
7
8   def up do
9     # Flip the values before we change the meaning of the column
10     execute("UPDATE users SET confirmation_pending = NOT confirmation_pending;")
11     execute("ALTER TABLE users RENAME COLUMN confirmation_pending TO is_confirmed;")
12     execute("ALTER TABLE users ALTER COLUMN is_confirmed SET DEFAULT true;")
13   end
14
15   def down do
16     execute("UPDATE users SET is_confirmed = NOT is_confirmed;")
17     execute("ALTER TABLE users RENAME COLUMN is_confirmed TO confirmation_pending;")
18     execute("ALTER TABLE users ALTER COLUMN confirmation_pending SET DEFAULT false;")
19   end
20 end