Context Overview and Use Cases
Contexts are used to manage ChangeSet deployments to databases in different environments. Examples of database environments are:
- Development Sandbox
- Development Integration
- Automated Test
- User Acceptance Test
- Staging
- Pre-Production
- Production
Because environmental contexts are extremely company and process dependent, Datical DB context tags are defined as freeform text to allows you to precisely match your environment.
Contexts are used to manage the deployment of ChangeSets. This enables you to target specific schema to specific environments.
Contexts are NOT case sensitive.
Setting the Context in ChangeSet Creation
ChangeSets are tagged with a context during their creation. This tag takes one of two forms – simple and complex contexts.
Context Tags
A context tag is a text string chosen from the list of contexts defined for a specific project. It is associated with a new ChangeSet.
Context Expressions
A context expression is one or more text strings chosen from the list of contexts defined for a specific project. The difference is that you will also specify an expression that describes how you want the context to be "matched."
For example, assume you have a simple project with 3 environmental contexts – Development, Test, and Production.
If you have a Change that you don't want deployed to Development, you would specify the Context in either of the following ways.
- !Development
- (Test or Production)
Context expressions can be built from any of the following operators:
- and
- or
- , (this is the same as or)
- ! (this is the not operator; it gives you a mechanism to negate the expression)
- () (the parenthesis are used for grouping)
Given that the context can be specified as arbitrarily complex expressions, you can create a new ChangeSet and precisely target the deployment to any combination of environments.
Using Contexts in Deployment
Now that the context (or context expression) is associated with a ChangeSet, you have 3 options for deploying the change.
Option 1 – Using the default context
When you setup a new Datical DB project or a new Step within a project, you can specify the environmental context (default) for the database instance. At deployment time, Datical DB will use the default context to evaluate the expression and determine is the ChangeSet should be applied to the database.
Option 2 – Specifying a context at deployment time
In addition to default contexts, you can also specify a context as a parameter for a specific deployment. Specifying a context at deploy time enables you to override the default context when you need to support one-off deployment situations.
Option 3 – No context specified on the step or during deployment
If no context is specified, then the ChangeSet will always be applied to the database.