From de98fb06a612d12acbd065fc935a75eef611edf5 Mon Sep 17 00:00:00 2001 From: Tom Konidas Date: Mon, 15 Jul 2024 19:44:50 -0400 Subject: [PATCH] Drop unique app name index It is possible two apps share the same name, however the package is the only thing that will stay unique. So we can safely drop the unique name db constraint, and let apps get added that are the same name. They will look different in most cases due to image/package. --- lib/plexus/schemas/app.ex | 1 - .../20240715234120_remove_apps_name_unique_index.exs | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 priv/repo/migrations/20240715234120_remove_apps_name_unique_index.exs diff --git a/lib/plexus/schemas/app.ex b/lib/plexus/schemas/app.ex index 63a75ad3..ee096569 100644 --- a/lib/plexus/schemas/app.ex +++ b/lib/plexus/schemas/app.ex @@ -22,7 +22,6 @@ defmodule Plexus.Schemas.App do app |> cast(params, [:package, :name, :icon_url]) |> validate_required([:package, :name]) - |> unique_constraint(:name) |> unique_constraint(:package, name: :apps_pkey) end end diff --git a/priv/repo/migrations/20240715234120_remove_apps_name_unique_index.exs b/priv/repo/migrations/20240715234120_remove_apps_name_unique_index.exs new file mode 100644 index 00000000..7a3b07cf --- /dev/null +++ b/priv/repo/migrations/20240715234120_remove_apps_name_unique_index.exs @@ -0,0 +1,7 @@ +defmodule Plexus.Repo.Migrations.RemoveAppsNameUniqueIndex do + use Ecto.Migration + + def change do + drop_if_exists index(:apps, [:name]) + end +end