diff --git a/backend/lib/edgehog/repo.ex b/backend/lib/edgehog/repo.ex index bf0cc6fcb..1065bdec5 100644 --- a/backend/lib/edgehog/repo.ex +++ b/backend/lib/edgehog/repo.ex @@ -23,16 +23,6 @@ defmodule Edgehog.Repo do require Ecto.Query - @tenant_key {__MODULE__, :tenant_id} - - def put_tenant_id(tenant_id) do - Process.put(@tenant_key, tenant_id) - end - - def get_tenant_id do - Process.get(@tenant_key) - end - def fetch(queryable, id, opts \\ []) do {error, opts} = Keyword.pop_first(opts, :error, :not_found) @@ -51,25 +41,6 @@ defmodule Edgehog.Repo do end end - @impl true - def prepare_query(_operation, query, opts) do - cond do - opts[:skip_tenant_id] || opts[:schema_migration] -> - {query, opts} - - tenant_id = opts[:tenant_id] -> - {Ecto.Query.where(query, tenant_id: ^tenant_id), opts} - - true -> - raise "expected tenant_id or skip_tenant_id to be set" - end - end - - @impl true - def default_options(_operation) do - [tenant_id: get_tenant_id()] - end - def transact(fun, opts \\ []) do transaction( fn -> diff --git a/backend/test/edgehog/tenants_test.exs b/backend/test/edgehog/tenants_test.exs index 3490b0202..09a6dd557 100644 --- a/backend/test/edgehog/tenants_test.exs +++ b/backend/test/edgehog/tenants_test.exs @@ -20,7 +20,6 @@ defmodule Edgehog.TenantsTest do use Edgehog.DataCase, async: true - @moduletag :no_tenant_fixtures alias Edgehog.Tenants alias Edgehog.Tenants.Tenant diff --git a/backend/test/support/data_case.ex b/backend/test/support/data_case.ex index 700ea9bb1..f42f3ce49 100644 --- a/backend/test/support/data_case.ex +++ b/backend/test/support/data_case.ex @@ -50,17 +50,6 @@ defmodule Edgehog.DataCase do setup tags do pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Edgehog.Repo, shared: not tags[:async]) on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end) - - if tags[:no_tenant_fixtures] do - :ok - else - # Create a tenant fixture and populate the tenant id, since we don't have the web part that - # does it for us here - tenant = Edgehog.TenantsFixtures.tenant_fixture() - _ = Edgehog.Repo.put_tenant_id(tenant.tenant_id) - - {:ok, tenant: tenant} - end end @doc """