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 diff --git a/test/plexus/apps_test.exs b/test/plexus/apps_test.exs index 10a7b8b3..5d13d8ab 100644 --- a/test/plexus/apps_test.exs +++ b/test/plexus/apps_test.exs @@ -83,12 +83,5 @@ defmodule Plexus.AppsTest do attrs = %{package: app.package, name: unique_app_name()} assert {:error, %Ecto.Changeset{}} = Apps.create_app(attrs) end - - test "with duplicate name returns error changeset" do - app = app_fixture() - - attrs = %{package: unique_app_package(), name: app.name} - assert {:error, %Ecto.Changeset{}} = Apps.create_app(attrs) - end end end diff --git a/test/plexus_web/controllers/api/v1/app_controller_test.exs b/test/plexus_web/controllers/api/v1/app_controller_test.exs index 5e835667..9db5d67c 100644 --- a/test/plexus_web/controllers/api/v1/app_controller_test.exs +++ b/test/plexus_web/controllers/api/v1/app_controller_test.exs @@ -70,14 +70,6 @@ defmodule PlexusWeb.API.V1.AppControllerTest do } = json_response(conn, 422) end - test "renders error when name is already taken", %{conn: conn} do - app = app_fixture() - attrs = %{@create_attrs | name: app.name} - - conn = post(conn, ~p"/api/v1/apps", app: attrs) - assert %{"errors" => %{"name" => ["has already been taken"]}} = json_response(conn, 422) - end - test "renders error when package is already taken", %{conn: conn} do app = app_fixture() attrs = %{@create_attrs | package: app.package}