DavidVII

DavidVII

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.

Showing Posts 1 to 8

hubertlepicki

hubertlepicki

I is an opinionated decision of framework authors. The reasoning is that you keep your bounded contexts separated this way, also on database level. But you do not have to do it, I certainly don’t and do not feel bad about it :wink:

yurko

yurko

I’d do the same

Aetherus

Aetherus

Sounds like we can create a poll :grimacing:

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

wtd423

wtd423

Wouldn’t it be super annoying to keep a table for each context synced? At least I rather deal with NULLs on non-shared columns than update shared columns for each table.

jeremyjh

jeremyjh

If you are using Postgres you can use table inheritance.

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).

bglusman

bglusman

I’d second the general pattern of not having the context prefix on database column, but I still have some different schemas for each context… my understanding is this is half the purpose of contexts/ schemas as opposed to models, as each schema uses only the columns relevant to that context, but it doesn’t stop other contexts from having many of the same columns or having relations between columns… in the accounts_users and payments_users example, I’d imagine its still just a users table, but the payment context might have a credit_card_id foreign relation there, and the accounts section might have a profile_id, but payments doesn’t care about a profile and accounts doesn’t care about a credit card, so they don’t bother having in their seperate schemas, and therefore a) they can’t be used from there carelessly, and b) you save pulling that data from the DB on each load since the schema doesn’t know about it, so don’t have to select specific columns to get the savings… and if one table gets a ton of columns from a ton of different contexts, it will be pretty easy to avoid seeing the impact and bloat of that in any one context.

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 #8
— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews