DavidVII

DavidVII

Phoenix 1.3 generators and table names

Hello, I’m curious about the reasoning behind prefixing the table names when creating a new resource via context generator. What would be the recommendation in the case that someone does what the docs refer to when mentioning that a resource may be a part of different contexts:

Note a resource may also be split over distinct contexts (such as Accounts.User and Payments.User).

What would be the recommended table name here? accounts_users or payments_users or something else?

I understand that you can change it, but being part of a generator somewhat implies that they want to drive the point that we should be thinking about things in terms of contexts and I’m curious what folks have to say about this.

Personally, I would just name my table users, but I’d like to hear from others and get a sense of the conversion.

Most Liked

josevalim

josevalim

Creator of Elixir

We have reverted this behaviour in master. Phoenix v1.3 will no longer prefix tables: Keep table names simple · phoenixframework/phoenix@c335147 · GitHub

10
Post #9
minhajuddin

minhajuddin

I too name my tables without prefixes. I believe that contexts should not permeate into the database. So, I always use the --table option while generating models. One of us should send a PR which allows adding a --drop-table-prefix to the generator config (and adding it to the switches).

Aetherus

Aetherus

Sounds like we can create a poll :grimacing:

By the way, I don’t add context prefix to table names, either.

Where Next?

Popular in Questions Top

albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43806 214
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 127536 1222
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement