Merge remote-tracking branch 'upstream/develop' into restrict-domain
[akkoma] / priv / repo / migrations / 20190315101315_create_registrations.exs
index fbb22ec7c5caec3b1ca746a7d4c292d73ee7d6f6..d705a499e4a692ab75027d66fdb4ee2edadd5d77 100644 (file)
@@ -2,17 +2,17 @@ defmodule Pleroma.Repo.Migrations.CreateRegistrations do
   use Ecto.Migration
 
   def change do
-    create table(:registrations, primary_key: false) do
-      add :id, :uuid, primary_key: true
-      add :user_id, references(:users, type: :uuid, on_delete: :delete_all)
-      add :provider, :string
-      add :uid, :string
-      add :info, :map, default: %{}
+    create_if_not_exists table(:registrations, primary_key: false) do
+      add(:id, :uuid, primary_key: true)
+      add(:user_id, references(:users, type: :uuid, on_delete: :delete_all))
+      add(:provider, :string)
+      add(:uid, :string)
+      add(:info, :map, default: %{})
 
       timestamps()
     end
 
-    create unique_index(:registrations, [:provider, :uid])
-    create unique_index(:registrations, [:user_id, :provider])
+    create_if_not_exists(unique_index(:registrations, [:provider, :uid]))
+    create_if_not_exists(unique_index(:registrations, [:user_id, :provider, :uid]))
   end
 end