What are the prevalent best practices for managing database of an application?
One option is to have an sql script to create the empty tables, and also to start with hardcoded options. (Say all locations, or profession types). During upgrade, you know whats in there and whats not, so on the server, run an sql script that adds columns and any new data.
Another is to do this programmatically, where everytime the server runs- it checks if the db exists, and if not, create it. And during addition of new columns- there would be code that would check if a certain column exists in this schema, and if not add it with a default value of my choice, and also any new data that should be needed.
My constraints are: 1) Should be blindly able to restore a backup if anything goes wrong. 2) Minimal manual intervention
Am I missing things here that I should add to the constraints? Please clarify your reasoning in relation to the answer.
Also, I hope that since I'm asking for a constrained answer along with sources and reasoning, this wouldn't count as a opinion based question.
Aucun commentaire:
Enregistrer un commentaire