mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 05:23:18 +12:00
37cc01957d
* 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`
30 lines
692 B
Elixir
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
|