Can both normal id and binary_id used as primary keys in same Phoenix project?

I have just created a new project using the --binary_id switch. My project is going to have at most three tables. The binary_id (UUID based) primary field would suit perfectly the main table. However, normal auto-increment integer based primary ids suit the other two tables better.

Is it possible to have both normal ids and binary_ids and primary keys for different tables in same project? Note: I am using PostgreSQL. Thank you.

Yes, that’s possible.

The option you mentioned just influences the generator and you can alter migrations and schema after generating them. But you really need to remember to do that before running the migration. Might be hard to change afterwards.

3 Likes