An ever-increasing number of organizations are implementing DevOps using a continuous delivery process. They are fueled by reports of the benefits, which include quicker time to market, reduced costs, and higher quality products.
Every organization has its own processes for compiling native code. It can be manual or automatic using Jenkins, Bamboo, etc., and the build system can be Maven, Make, or others. But all builds have one thing in common that the build process relies on.
Each build starts with an empty folder, then gets the relevant source code files from the file-based version control repository (SVN, Git, Perforce, Microsoft TFS, IBM RTC, etc.). It then compiles the source code files, and, if the compilation succeeds, the process can continue to the next step, which is to deploy to an automated test environment. Some organizations also save the compilation phase output (binary artifacts) result in a binary source control repository (SVN, Git, Perforce, TFS, RTC, etc.) so the deployment process can retrieve the relevant artifacts from the file-based (binaries) source control repository.
Deployment to an automatic test environment process can be done differently in diverse organizations. One company might do it manually, a second might run scripts, and third might use an application release automation tool, such as IBM UrbanCode Deploy or CA Release Automation. The common factor for all deployments is copying the artifact (binary) to the relevant server while overriding what was done before.
Every change a developer makes must be documented in the source control repository. If it doesn't exist in the source control repository, it is not included in the build process. Furthermore, if a developer copies an artifact generated locally to a test environment, the next deployment will override this out-of-process change.
Occasionally, defects will only bed recreated in test environments, but due to infrastructure limitations (like storage, costs, and complex architecture) the developer is required to work in the test environment and not in the development environment. In those cases, the developer may need to copy the locally generated artifact directly to the test environment. Once the developer checks in the code changes, the next deploy to the test environment will override the locally generated artifact with an artifact from the binaries source control. This built-in safety net in the process prevents out-of-process, locally generated artifacts from entering into the production environment.
The database code has similar characteristics to native code but also has some inherent differences, which require adjustments to the source control infrastructure from perspectives of native code development, build, and deploy.
A database code deployment is done by running SQL scripts (DDL, DCL, and DML), which change the current structure and data to the desired version. When comparing database deployment to native code deployment, the differences are crystal clear. Native code deployment is done by copying the new binaries (DLL, jar, etc.) to the target environment. The previous version of the artifact is no longer valid and may be saved for a quick rollback. This is the safety net that prevents out-of-process artifacts from reaching the production servers.
This is not the case with database code deployment. The script changes version A to version Z via many DDL, DCL, and DML commands — with every command changing the version a little bit. If the current version of the database is not A, there are two possible outcomes:
- The script will ignore current version and override the structure with whatever exists in the script.
- The script will fail. For example: trying to add a column that already exists with a wrong data type.
An error in a deployment process is not usually a desirable outcome. In this case, however, getting the error is better than having the script run successfully and then without warning, revert changes made to production as an emergency fix or changes made in the trunk/stash. These changes would have been made by a different team or merged from a different branch.
The input of the deployment phase is SQL script(s), which are generated in the build phase.