Is there a way to use an existing schema for creating relationships in an Ash Resource


I have an existing ecto schema say “Organization”.
Now I have Ash.Resource say Branch
Is there a way to create relationship like

relaltionships belongs_to :org, Organization end
A way to wrap an existing schema and use it as a Ash.Resource. Please guide.
BTW loving the way Ash is progressing. I am betting my new venture on Ash.


1 Like

There is not a way to do this unfortunately. You’ll need to make an Organization resource if you want to use relationships with it.

1 Like

@zachdaniel The resource can be an existing table managed by another schema as well right? I don’t see Ash restricting that. In this case, Organization can be both a plain Ecto Schema as well as an Ash Resource?

I use mix phx.gen.auth for generating my auth schemas and liveview endpoints. I haven’t switched to use Ash Authentication yet. However, I still need to refer to the User records in my Ash Resources. So I created a resource file for the existing User schema with only email field (I don’t want the password fields exposed on my Ash Resoruce) and it works fine. Not sure, if this has any drawbacks. It would be good to know from you.


Correct, no issues there.


postgres do
  migrate? false

To skip Generating migrations for it


Good heavens, I should spend more time reading the Ash docs. It is truly pragmatic.

1 Like