Nowadays the question “Why put database under source control?” no longer makes sense. Probably “How to put database under source control?” is now the correct question.
But before answering the second question let me answer the first identifying the reasons that led me/us team to invest on database source control:
- Is the first step of database automation
- In other words, if you want to assemble a database deployment pipeline you should put your database changes into a source control system;
- Keep history of each change
- Allows traceability:
- Everything went well: just do it and forget it;
- Something was broken: you will need to know what changed, when was changed, why it was changed and who changed it;
- Allows traceability:
- Your best communication system
- Allows to share code (SQL scripts);
- In team context a source control system helps to manage possible conflict of interest;
- Enforce standards (my reference was Sjors Takes)
- Standards, preferably combined with automation, help to reduce/eliminate conflicts.
How to put database under source control? is the question that follows.