Over a million developers have joined DZone.

The Difference Between Source Control for Native Code and for the Database

As developers flock to DevOps for its speed and efficiency, it's important to note the differences between most projects and databases.

· Database Zone

Build fast, scale big with MongoDB Atlas, a hosted service for the leading NoSQL database. Try it now! Brought to you in partnership with MongoDB.

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.

DevOps is mostly about organizational culture, while continuous delivery and continuous integrations are mainly about automation and tests, which require a trustworthy source control.

Native Code

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.

Database Deployment

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:

  1. The script will ignore current version and override the structure with whatever exists in the script.
  2. 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.

Now it's easier than ever to get started with MongoDB, the database that allows startups and enterprises alike to rapidly build planet-scale apps. Introducing MongoDB Atlas, the official hosted service for the database on AWS. Try it now! Brought to you in partnership with MongoDB.

source control,repository,continuous delivery,database,native,test environment,deployment,devops

Published at DZone with permission of Yaniv Yehuda, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}