Dynamic schema name

Ah, gotcha.

The use Ecto.Schema macro creates a __schema__ function that exposes some introspection details about your schema, and you can use that to find the actual table name as string (Ecto.Schema — Ecto v3.14.0)

def test(schema_name) when is_atom(schema_name) do
  # Get the table name as string
  table_name = schema_name.__schema__(:source)
  Test.Repo.all(from a in table_name, where: a.name == "ACME", select: a.id)
end

Hope this helps!