mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 13:33:50 +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`
43 lines
863 B
Elixir
43 lines
863 B
Elixir
defmodule AshPostgres.Test.PostLink do
|
|
@moduledoc false
|
|
use Ash.Resource,
|
|
domain: AshPostgres.Test.Domain,
|
|
data_layer: AshPostgres.DataLayer
|
|
|
|
postgres do
|
|
table "post_links"
|
|
repo AshPostgres.TestRepo
|
|
end
|
|
|
|
actions do
|
|
default_accept(:*)
|
|
|
|
defaults([:create, :read, :update, :destroy])
|
|
end
|
|
|
|
identities do
|
|
identity(:unique_link, [:source_post_id, :destination_post_id])
|
|
end
|
|
|
|
attributes do
|
|
attribute :state, :atom do
|
|
public?(true)
|
|
constraints(one_of: [:active, :archived])
|
|
default(:active)
|
|
end
|
|
end
|
|
|
|
relationships do
|
|
belongs_to :source_post, AshPostgres.Test.Post do
|
|
public?(true)
|
|
allow_nil?(false)
|
|
primary_key?(true)
|
|
end
|
|
|
|
belongs_to :destination_post, AshPostgres.Test.Post do
|
|
public?(true)
|
|
allow_nil?(false)
|
|
primary_key?(true)
|
|
end
|
|
end
|
|
end
|