Ash FrameworkAF
Ash Framework6mo ago
6 replies
Joan Gavelán

Bypassing Multitenancy on Destroy Actions

My goal is to delete any invitation that is expired using a cron job (Oban)
destroy :delete_expired_invitation do
  multitenancy :bypass
  filter expr(expires_at <= now())
end

But multitenancy doesn't seem to be a valid option for the destroy action DSL, and I'm not sure about the filter line there either 🤔 what can I do in this case?
Solution
This is working though

MyApp.Establishments.Invitation
|> Ash.Query.for_read(:expired)
|> Ash.bulk_destroy!(:destroy, %{}, authorize?: false, tenant: :bypass)
Was this page helpful?