ash_postgres/lib/verifiers/ensure_table_or_polymorphic.ex

31 lines
692 B
Elixir
Raw Normal View History

defmodule AshPostgres.Verifiers.EnsureTableOrPolymorphic do
2023-09-23 08:14:25 +12:00
@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