2020-10-29 15:26:45 +13:00
|
|
|
defmodule AshPostgres.MultitenancyTest.Post do
|
|
|
|
@moduledoc false
|
|
|
|
use Ash.Resource,
|
|
|
|
data_layer: AshPostgres.DataLayer
|
|
|
|
|
|
|
|
attributes do
|
2021-01-13 14:27:39 +13:00
|
|
|
uuid_primary_key(:id, writable?: true)
|
2021-01-13 14:22:28 +13:00
|
|
|
attribute(:name, :string)
|
2020-10-29 15:26:45 +13:00
|
|
|
end
|
|
|
|
|
|
|
|
actions do
|
2022-04-20 03:08:28 +12:00
|
|
|
defaults([:create, :read, :update, :destroy])
|
2020-10-29 15:26:45 +13:00
|
|
|
end
|
|
|
|
|
|
|
|
postgres do
|
|
|
|
table "multitenant_posts"
|
|
|
|
repo AshPostgres.TestRepo
|
|
|
|
end
|
|
|
|
|
|
|
|
multitenancy do
|
2020-11-03 16:59:51 +13:00
|
|
|
# Tells the resource to use the data layer
|
|
|
|
# multitenancy, in this case separate postgres schemas
|
2021-01-13 14:22:28 +13:00
|
|
|
strategy(:context)
|
2020-10-29 15:26:45 +13:00
|
|
|
end
|
|
|
|
|
|
|
|
relationships do
|
2021-01-13 14:22:28 +13:00
|
|
|
belongs_to(:org, AshPostgres.MultitenancyTest.Org)
|
2021-07-25 03:28:58 +12:00
|
|
|
belongs_to(:user, AshPostgres.MultitenancyTest.User)
|
2020-10-29 15:26:45 +13:00
|
|
|
end
|
|
|
|
end
|