While generating new module using mix phx.gen.json commands, I always find Database primary column is auto generated as id bigint NOT NULL DEFAULT. Is there any reason why Phoenix framework forces application to use id bigint as primary key?
I suspect the unasked question here is “Why not use regular int? It’s smaller.”
When your table is small, the difference between int and bigint is small. And with storage mostly being cheap nowadays, it does not matter that you use bigint for your table.
If your table starts growing big, you will need to then look at bigint anyway. If you started with int, you will need to do a migration and also keep monitoring that you do the migration early enough, before things start crashing. If you already started with bigint, you’ve got so much room that your table will practically never run out of IDs.
These combined make bigint a more practical choice for the majority of cases and thus a good default.
BTW, Phoenix does not force you to use bigint, it suggests this in its autogeneration, but you could easily change this be a uuid, by adding a config option.