Hacker News new | ask | show | jobs
by jkingsbery 1648 days ago
> The common way I know is the access is given to a small number of trusted people who make the updates.

I think this was a common way of doing it 10+ years ago, but what I've seen work the best is to have your CI/CD process apply the updates. Assuming the migration scripts follow the same process as all your other code (code reviewed, tested, and are runnable), automatically applying these scripts is much less error prone than having a person apply them. Humans are pretty terrible at following a script, which is one of the things computers are great at.

Some objections I've seen to relying on automatic deployments:

- "But we should have a person run them to make sure they do they right thing!" Agreed, you should, but that should happen at test time, or maybe code review time, not right before you are about to apply something into production the Shift Left [1] principle applies to database changes as well as code changes

- "What if something goes wrong?" Well, what if something goes wrong with any of your deployments? Usually, you can roll back (either literally rolling back, or rolling forward, or rolling in some other direction that leaves your system in an ok state), look at the logs to see what went wrong, and try again.

- "But data can get messed up!" Data can get messed up by code changes. You should have a backup/disaster recovery process.

[1] https://en.wikipedia.org/wiki/Shift-left_testing