There has been some discussion on the SO community wiki about whether database objects should be version controlled. However, I haven't seen much discussion about the best-practices for creating a build-automation process for database objects.
This has been a contentious point of discussion for my team - particularly since developers and DBAs often have different goals, approaches, and concerns when evaluating the benefits and risks of an automation approach to database deployment.
I would like to hear some ideas from the SO community about what practices have been effective in the real world.
I realize that it is somewhat subjective which practices are really best, but I think a good dialog about what work could be helpful to many folks.
Here are some of my teaser questions about areas of concern in this topic. These are not meant to be a definitive list - rather a starting point for people to help understand what I'm looking for.
- Should both test and production environments be built from source control?
- Should both be built using automation - or should production by built by copying objects from a stable, finalized test environment?
- How do you deal with potential differences between test and production environments in deployment scripts?
- How do you test that the deployment scripts will work as effectively against production as they do in test?
- What types of objects should be version controlled?
- Just code (procedures, packages, triggers, java, etc)?
- Indexes?
- Constraints?
- Table Definitions?
- Table Change Scripts? (eg. ALTER scripts)
- Everything?
- Which types of objects shouldn't be version controlled?
- Sequences?
- Grants?
- User Accounts?
- How should database objects be organized in your SCM repository?
- How do you deal with one-time things like conversion scripts or ALTER scripts?
- How do you deal with retiring objects from the database?
- Who should be responsible for promoting objects from development to test level?
- How do you coordinate changes from multiple developers?
- How do you deal with branching for database objects used by multiple systems?
- What exceptions, if any, can be reasonable made to this process?
- Security issues?
- Data with de-identification concerns?
- Scripts that can't be fully automated?
- How can you make the process resilient and enforceable?
- To developer error?
- To unexpected environmental issues?
- For disaster recovery?
- How do you convince decision makers that the benefits of DB-SCM truly justify the cost?
- Anecdotal evidence?
- Industry research?
- Industry best-practice recommendations?
- Appeals to recognized authorities?
- Cost/Benefit analysis?
- Who should "own" database objects in this model?
- Developers?
- DBAs?
- Data Analysts?
- More than one?