ash_postgres/lib/verifiers/ensure_table_or_polymorphic.ex
Zach Daniel 37cc01957d
improvement!: 3.0 (#227)
* WIP

* chore: fix mix.lock merge issues

* improvement: upgrade to 3.0

* chore: remove `repo.to_tenant`

* chore: continue removal of unnecessary helper

* chore: use `Ash.ToTenant`
2024-03-27 16:52:28 -04:00

30 lines
692 B
Elixir

defmodule AshPostgres.Verifiers.EnsureTableOrPolymorphic do
@moduledoc false
use Spark.Dsl.Verifier
alias Spark.Dsl.Verifier
def verify(dsl) do
if Verifier.get_option(dsl, [:postgres], :polymorphic?) ||
Verifier.get_option(dsl, [:postgres], :table) do
:ok
else
resource = Verifier.get_persisted(dsl, :module)
raise Spark.Error.DslError,
module: resource,
message: """
Must configure a table for #{inspect(resource)}.
For example:
```elixir
postgres do
table "the_table"
repo YourApp.Repo
end
```
""",
path: [:postgres, :table]
end
end
end