70f8dc63d184f088e89cf14bea84021732ffb40c
[anni] / priv / repo / migrations / 20170522160642_case_insensivtivity.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.CaseInsensivtivity do
6   use Ecto.Migration
7
8   # Two-steps alters are intentional.
9   # When alter of 2 columns is done in a single operation,
10   # inconsistent failures happen because of index on `email` column.
11
12   def up do
13     execute("create extension if not exists citext")
14
15     alter table(:users) do
16       modify(:email, :citext)
17     end
18
19     alter table(:users) do
20       modify(:nickname, :citext)
21     end
22   end
23
24   def down do
25     alter table(:users) do
26       modify(:email, :string)
27     end
28
29     alter table(:users) do
30       modify(:nickname, :string)
31     end
32
33     execute("drop extension if exists citext")
34   end
35 end