Database development policies

Applies to
ApexSQL Source Control

Summary
This article explains how to work with the Database development policies feature in ApexSQL Source Control.

Description
ApexSQL Source Control provides a possibility to establish and enforce behaviors among developers regarding source control, for example mandatory locking of files on checkout. These rules are enforced in ApexSQL Source Control via Database development policies. ApexSQL Source Control has three policies implemented: Optional, Permissive and Restrictive. The feature is available in the shared database development model only.

Optional policy

This is the policy set by default. When the Optional policy is set, each developer can work on an object without the need to perform a check out or lock before editing:

If developer A makes changes to an object, they will be overwritten if developer B makes additional changes.

Having the optional policy enabled (which is in reality having no policy) requires the team to communicate outside ApexSQL Source Control in order to avoid overriding each other’s changes

Permissive policy

By setting the Permissive policy, a requirement is created that each object must be checked out before editing:

An object can be checked out from the Object Explorer, by choosing the Check out option from the ApexSQL Source Control menu:

As soon as the object is checked out, it can be edited. To see if the object is checked out, note the icon on the object. A green check mark indicates that it has been checked out by you:

If an object is not checked out, (while the Permissive policy is active) ApexSQL Source Control will prevent any developer to make any changes against it, enforcing the requirement that it must be checked out first.

In such cases, the following warning dialog will appear:

It is possible, to Check out an object that is already checked out by someone else

When checking out an object already checked out by someone else, a dialog appears with the information about the user who checked out an object. To override the check out, click the Yes button:

Restrictive policy

The Restrictive policy requires that the object must be locked before editing. Note: the Lock operation cannot be overridden:

While the Restrictive policy is enabled, each developer must Check out and lock an object before editing.

If an object is checked out and locked, the developer who locked the object is the only one who can edit it.

To Check out and lock an object, right click on it from the Object Explorer and from the ApexSQL Source Control menu, select the Check out and lock option:

When an object is locked, the object icon will be changed in the Object Explorer to reflect the locked status:

If an object is not locked, (while the Restrictive policy is active) ApexSQL Source Control will prevent making any changes against an object, enforcing the requirement that the object must be locked prior to editing. The following warning appears:

If another developer checked out and locked an object, it cannot be edited by any other developer.

Since the Lock command cannot be overridden, there is no possibility for the rest of the team to override a lock, until it is released by a developer who performed the Lock operation, or until the changes made against an object are committed.

Q: What is the scope of a database policy?

A: Database development policies are applied against the entire database.

Q: Will database development policies be applied on objects that are not included in source control?

A: Yes, policies will be applied against all database objects, even if they are not included in the source control.

Q: Is there an option to change the scope of a database policy?

A: No

Q: Do I need to use a database policy if I’m the only one who works on a database?

A: No, database development policies are designed for a team working on the same database.

Q: Is there a way I can set a group of users that must follow the rules set by the database policy?

A: By default, all users are included in the scope of the policy.

Q: Can I apply database development policies while using the dedicated development model?

A: No, database development policies can be applied only if you are working in the shared database development model.

Q: Will the users who did not install ApexSQL Source Control be affected with database policy settings, in case they are working on a database where policies are applied?

A: Yes, all users will be affected with database policy settings no matter if ApexSQL Source Control is installed on a local machine.

Q: Is there a quick overview of the status of all objects, so that I can find if an object that I want to work on is checked out or locked, without searching it in the Object Explorer?

A: Yes, ApexSQL Source Control has the Object status feature implemented. To see the status of all objects, right click the database, and from the ApexSQL Source Control menu, select the Object status option:

A list of all objects that are included in source control will be shown, along with the status of each object and the user who changed the status: