Has anyone worked on deriving database tables, forms, and views from the model?

I’m getting a bit more familiar with the Phoenix/LiveView stack now, and one thing that I sorely miss from other stacks is automatically generating database tables, forms, and views based on the model. The generators work okay for getting started, but it’s hard to keep them in sync with changes. I’m also just not a huge fan of code generation, for the fact that it leaves you with lots of boilerplate that you now have to try and keep in sync with your domain.

Django is a great example in this space, but there are a few others in other languages.The forms and views are usually extremely simplistic. Even just an admin view of the models that stayed in sync with the changes made to the models would be sweet.

So much of my work is spent in the “model every thing and get the basics working” and hardly any is in the “polish it up and make it look Enterprise-y”. So something that could derive all of the basic CRUD stuff would be amazing!

I’ll probably take something like this on if no one has made any progress here yet.

https://www.ash-hq.org/ I think this might be along the lines of what you’re looking for.

1 Like

Ash has a similar philosophy of deriving stuff from the domain.

I used it a little bit and found it very nice, there are libraries to derive JSON APIs, GraphQL servers, a Postgres data layer, etc.

It is also built to be very extensible, so you could write a library to derive basically anything.

Thanks! Not exactly though, Ash doesn’t provide database migrations, automatic forms, or generic views.

So, it does generate things from your models, just none of the things I was asking for :grimacing:

Sorry I don’t have links because I’m on my phone but there have been some admin packages released over the years that may do what you want. One is called LiveAdmin.

Ash is a solid foundation for what you are looking for. These building blocks are just not built yet. If you can contribute, it would be great.

The Ash extension LiveAdmin is old and depends on an outdated version of surface. Has to be updated.

It took its time for phoenix and ecto to get into their current stable state, then liveview took its time and now we have to wait for ash and then even longer for ash extensions that fulfill your requirements. I guess it will take another 3-5 years to have database migrations, a rich public component selection (including paginated, filtered tables), automatic forms and such.

Sadly the community is rather small and fields to potentially contribute to are broad (from embedded systems/nerves over ai/nx to web/phoenix) that development on each field basically depends on a handful developers, so nothing happens fast. So I recommend looking at ash and there especially at pyro (which describes itself as Phoenix components and tooling with (optional) declarative UI for Ash Framework).


Ash does handle migrations for you.

The way it works is you define your resources, define attributes on them, relationships and identities. There’s a mix command that will take these and generate a migration file for you. The resources derive to database tables, attributes to columns, relationships to foreign keys, and identities to unique indexes. It even handles renaming of attributes.

Regarding automatic forms, there is a new project in this area called Pyro that derives UI from Ash resources.


Yep! Commenters here are correct in that Ash is likely the closest you’ll get to what you want in the elixir ecosystem. While we don’t have the generic views/forms, we absolutely will (as an optional extension) before long.

1 Like

And we do handle your migrations (human still has to be on the loop, reviewing database changes and things like that)