sooo… table names have to be plural? This seems like an odd choice. In all of the companies I have ever worked in, everybody always used singular table names. It is certainly not intuitive that that is a hard requirement.
What happens to entities whose names cannot be properly pluralized?
I have closed the issue I opened earlier.
It’s a common pattern in Ruby on Rails, which Ecto and Phoenix have taken inspiration from heavily. It’s the convention used here. Nothing is stopping you from using singular table names, just don’t expect the generators to work when straying outside of convention.
Nah, I think I do not have the energy to fight an established convention like that; it is a matter of opinion after all, in which I (and all of my colleagues, who I will never convince, because we use raw sql all day, where you INNER JOIN ON apple.shape = otherapple.shape, you know) firmly fall into the “other” camp.
I can accept that people do this, but I do not wish to do this myself.
I’m using sqlite3 in production on a client project for years. There’s certainly space to improve, but it’s also very possible to use. However it’s been ages since I last used phoenix generators besides for creating an initial new project.
Hey, if you want to get used to it that’s cool, but it’s literally just editing two tokens each time. The convention doesn’t affect anything other than the generators.
Ya, sqlite is crazy fast. It’s even recommended not to worry about N+1 since you’re reading from a consistently open file (not that you have a choice with Ecto, though).
Ah, that is good to know. I’m a recent sqlite convert and really loving it. I have high hopes for LiteFS. I guess there’s no elegant way around Ecto preloads, though? Obviously there is manually looping but I wouldn’t call that elegant I assume that would be a micro optimization anyway?
I have tried ecto in 2019, but it did not click with me back then. But I urgently needed mssql support, which also was not ready, so maybe it has not been ecto’s fault.
Now I want to try again. I still have nightmares from Hibernate and Entity Framework sometimes.
Do all of you not use generators? I resent form building and ui validation for CRUD. Do you all code these things by hand or is there something I should know other than generators?
The only generator I use day to day is mix ecto.gen.migration everything else is build as I need it. None of the generators produce even close to what we have for our admin panel and structuring. That has been my experience with generators (rails, django, phoenix, etc…) for the last 8 years.
Ya, I do by hand with help of editor snippets. For example I type defm<space> which expands to:
@impl true
def mount(_params, _session, socket) do
| # <- cursor
{:ok, socket}
end
and then type sa=<space> to get:
@impl true
def mount(_params, _session, socket) do
socket =
socket
|> assign(|)
{:ok, socket}
end
It’s actually recommended not to use the builtin generators for anything other than learning (sorry, I can’t find the citation). You end up tweaking them a bunch anyway. If you find yourself in a consistent pattern you like you can always make your own.
I’ve had the same experience as @warmwaffles… I use them for generating migrations and phx_new. I think that is pretty common!