srikanthkyatham
Is there a way to use an existing schema for creating relationships in an Ash Resource
Hi
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.
-Srikanth
Marked As Solved
zachdaniel
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.
Also Liked
shankardevy
@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.
zachdaniel
Correct, no issues there.
Add
postgres do
migrate? false
end
To skip Generating migrations for it
srikanthkyatham
Good heavens, I should spend more time reading the Ash docs. It is truly pragmatic.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









