Switching to a long is far from a clean solution. There is only one reasonable option if you are too large: UUID ( yes, PostgreSQL comes with the uuid data type ).
128 bits have a size of 4 integers, but you donβt want to go through the entire application in a few years, and all this again, right? UUIDs will work when you get too big and you need to outline your data. After that, you cannot have a common sequence, so UUIDs make sense.
As a bonus, you can even save your unique property on each line.
Migration is not so complicated: adding a column with NULL in PostgreSQL is cheap, so you can add a column first and then perform online migration in batches where you update several thousand records at a time, t there is downtime.
Then you can test the same code with both foreign keys. Does Java have something similar to a laboratory or scientist ?
Will it be a ton of work? Yes, but this is obviously a good sign if you have an application that is so popular.
I also hope that you learned the lesson using the same sequence for all tables. Honestly, I do not see this as an added value. If you want to know where the object is located, you can also name primary keys in different ways (for example, room_id, reservation_id, etc.).
source share