Shared server development with version control

Shared server with version control
In this setup the Development system holds the "master"-version of the system. This means all developers work on the same working copy. But the source code is also checked in. However non versioned code may be deployed.

Setup

The following computer setup is needed.

  • Development system - A development system that acts as a deploy source.
  • Version control system
  • Deploy target (usually a Stage-system). See Deploy setups
graph TD Central[Development system] --> DeployTarget[Deploy target] Central --> VCS[Version control system]

Database model changes

Database model changes can be made through Database Designer or through external tools like SSMS. If changes are made through external tools (for example SSMS) the deploy script has to be added manually.

System changes

The changes are made directly to the Development system. Through the admin-interface or SSMS.

To push changes to the version control system the developer should:

  1. Make the changes.
  2. Check out the latest version of the code from the version control system.
  3. DbSync.exe -SqlModulesFromDatabase or DbSync.exe -FromDatabase from the central database to their local checkout of the repository. See DbSync.
  4. Push changes to the version control system.

Versioning table content

To version table content in addition to versioning SQL objects. Use the -FromDatabase flag instead of -SqlModulesFromDatabase.

This requires the the file in this folderDatabase/Tables/CustomTables.xml. Download an example of CustomTables.xml.

Review

An external tool compatible with the version control system should be used for code review.

Getting other peoples' changes

All developers are working in the same copy of the system, meaning everyone will instantly get all changes. This also means one developer may break another developers code, or they might overwrite each others changes. Developers must coordinate so two developers does not work on the same objects.

Deploy

The normal deploy flow i used from the Development system. All developers need to coordinate so there are nothing in half-state in the development system at the time of deploy.

DbSync

DbSync is usually called using a cmd file. Exacly what parameters are used is specific to the project. These are some common setups:

Only SQL objects

DbSync.exe -SqlModulesFromDatabase -Database ExampleDatabase -Server localhost\SqlExpress -ModuleIds 1 -NoStubs -IgnoreChangesByOtherUsers

SQL objects and table content

DbSync.exe -FromDatabase -Database ExampleDatabase -Server localhost\SqlExpress -ModuleIds 1 -NoStubs -IgnoreChangesByOtherUsers

See Basic version control using DbSync for more info.