2024-03-28 09:52:28 +13:00
|
|
|
defmodule AshPostgres.Verifiers.EnsureTableOrPolymorphic do
|
2023-09-23 08:14:25 +12:00
|
|
|
@moduledoc false
|
2024-03-28 09:52:28 +13:00
|
|
|
use Spark.Dsl.Verifier
|
|
|
|
alias Spark.Dsl.Verifier
|
2021-01-29 13:42:55 +13:00
|
|
|
|
2024-03-28 09:52:28 +13:00
|
|
|
def verify(dsl) do
|
|
|
|
if Verifier.get_option(dsl, [:postgres], :polymorphic?) ||
|
|
|
|
Verifier.get_option(dsl, [:postgres], :table) do
|
|
|
|
:ok
|
2021-01-29 13:42:55 +13:00
|
|
|
else
|
2024-03-28 09:52:28 +13:00
|
|
|
resource = Verifier.get_persisted(dsl, :module)
|
2023-09-05 03:25:03 +12:00
|
|
|
|
|
|
|
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]
|
2021-01-29 13:42:55 +13:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|