Merge branch 'account-notes' into 'develop'
[akkoma] / priv / repo / migrations / 20170522160642_case_insensivtivity.exs
index c7565946e022b342a6f794789d3517e396529f05..9a67727e9965830d39e9c2c5bc00b7aacbac855e 100644 (file)
@@ -1,19 +1,31 @@
 defmodule Pleroma.Repo.Migrations.CaseInsensivtivity do
   use Ecto.Migration
 
+  # Two-steps alters are intentional.
+  # When alter of 2 columns is done in a single operation,
+  # inconsistent failures happen because of index on `email` column.
+
   def up do
-    execute ("create extension if not exists citext")
+    execute("create extension if not exists citext")
+
+    alter table(:users) do
+      modify(:email, :citext)
+    end
+
     alter table(:users) do
-      modify :email, :citext
-      modify :nickname, :citext
+      modify(:nickname, :citext)
     end
   end
 
   def down do
     alter table(:users) do
-      modify :email, :string
-      modify :nickname, :string
+      modify(:email, :string)
     end
-    execute ("drop extension if exists citext")
+
+    alter table(:users) do
+      modify(:nickname, :string)
+    end
+
+    execute("drop extension if exists citext")
   end
 end