But in general this is my(our) process.
- First I write the code.
- Then I test the code locally.
- Then I test the code on an instance with a copy of prod data. If I want to debug at this point, I run the web process locally while my DB configuration points at that specific server with the prod data.
- If it's code that spans across more than one subsystem(e.g. it also involves async celery task/queue servers) I test on a staging environment, that duplicates(as much as possible) the prod infrastructure.
- Then I deploy.
Obviously there are other various details, plus rollback plans in case something still goes wrong, but that's the gist of it.