Hey guys, I was just wondering if it's possible to...
# orm-help
e
Hey guys, I was just wondering if it's possible to @map two different Prisma fields to one column in a MySql db
r
@Esau Kang 👋 I don’t think that’s possible.Could you share your use case for this?
e
Hey there @Ryan, thanks for the speedy response. I'm adding a new field with a specific name to an existing codebase where the new field will always be the same as the value from another field.
It's not a huge issue, this would just have been the easiest way to implement it
i.e. userId, id, profileId under user is always the same, so I'd like them all to map to an "id" column in the DB without having to do anything else
r
If you’re using Postgres, you can use the
generated
identifier for this to make sure all values are same 🙂
e
Thanks man, I'll keep that in mind. Cheers 🙂
r
Something like :
Copy code
create table "user" (
	"id" serial primary key,
	"userId" int generated always as ("id") stored,
	"profileId" int generated always as ("id") stored
);
Let me know if this works 🙂
e
I'm using mysql, but I found the relevant generated key. thank you so much for pointing me in the right direction! 🙂
🙌 1