On one of the projects I'm working on we've decided to switch to using UUIDs as our publicly facing identifiers (in routes, API requests, etc). The motivation behind this is that the business does not want to competitors to know how we a tracking in terms of business metrics, which can sometimes be deduced from the changes in integer ids.
Next up, we need to actually add the UUID column to all of our database tables and populate it with an automatically generated UUID.
To migrate each table, we need to execute a few steps in order: To do this, we loop over each one of the model classes defined int the MODEL_CLASSES constant.
We do this in chunks of 1000 to ensure that we don't accidentally run out of memory, and also consider soft deleted records (we're going to add a NOT NULL constraint to the table, so every single row need a UUID).