> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/database-devops/use-db-devops/deployment-pipeline-configuration/schema-git-connector-expressions.md).

# Use Expressions for the DB Schema Git Connector

Set the DB Schema Git connector, repository, schema file path, and archive path from a pipeline expression or runtime input.

On a database schema that uses a Harness connector as the changelog source, you can set source fields to a fixed value, a pipeline expression, or a runtime input. Harness resolves those values when the pipeline runs and uses them to clone the changelog.

Use this when environments need different Git connectors, repositories, or changelog paths, without editing the schema before every run. Every Database DevOps step that uses the schema honors these expressions, including Apply DB Schema, Rollback DB Schema, Update SQL, Rollback SQL, Liquibase Command, Flyway Command, and DB Test and Preview.

***

## Before you begin

* **DB Schema with Connector:** A database schema with **Connector** selected under **How do you want to connect to your data schema?**.
* **Database DevOps pipeline:** A pipeline that can supply the variables or runtime inputs. Go to [Create a pipeline in Database DevOps](https://developer.harness.io/database-devops/use-db-devops/deployment-pipeline-configuration/create-a-pipeline.md) to create one.

***

## Supported fields

If a field shows **Convert to expression** in the UI, you can set it to an expression or a runtime input.

| Field                          | Fixed value | Expression or runtime input |
| ------------------------------ | ----------- | --------------------------- |
| **Connector**                  | Yes         | Yes                         |
| **Repository**                 | Yes         | Yes                         |
| **Path to Schema File**        | Yes         | Yes                         |
| **Archive path** (Artifactory) | Yes         | Yes                         |

![Edit Database Schema with Connector and Repository set to pipeline variable expressions](https://4089095456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWwqb27iUU3gZvwGNroZp%2Fuploads%2Fgit-blob-b1431774004e2921a45fef83da4215922536519d%2Fdb-devops-schema-connector-expression.png?alt=media)

{% hint style="info" %}
**Account-type and repository-type Git connectors**

If the resolved connector is a **repository-type** Git connector, Harness clones that repository. If it is an **account-type** Git connector, set **Repository** (fixed value or expression) to the repository to clone. In both cases, **Path to Schema File** still comes from the schema.
{% endhint %}

***

## Supported expression forms

The following forms are supported on fields that allow expressions:

| Form                              | Example                                    |
| --------------------------------- | ------------------------------------------ |
| Pipeline variable                 | `<+pipeline.variables.connector_name>`     |
| Stage variable                    | `<+stage.variables.connector_name>`        |
| Runtime input                     | `<+input>`                                 |
| Runtime input with default        | `<+input>.default(my-git-connector)`       |
| Runtime input with allowed values | `<+input>.allowedValues(dev-git,prod-git)` |

***

## Configure the schema and pipeline

{% stepper %}
{% step %}

### Add pipeline variables

Open your Database DevOps pipeline, and then click **Variables**.

Under **Custom Variables**, add variables for the values you want to resolve at runtime. For example:

* **connector\_name:** The Git connector identifier.
* **repo\_name:** The repository name.

You can leave a value empty and supply it as a runtime input when you run the pipeline.

![Pipeline custom variables for connector\_name and repo\_name](https://4089095456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWwqb27iUU3gZvwGNroZp%2Fuploads%2Fgit-blob-bd4bd356e030d9f2cf1e13d5a538109cda8d643f%2Fdb-devops-schema-connector-pipeline-variables.png?alt=media)
{% endstep %}

{% step %}

### Set expressions on the DB Schema

To configure the schema connection fields, perform the following:

1. In **Database DevOps**, click **DB Schemas**.
2. Next to the schema, click (**⋮**), then select **Edit**.
3. Under **How do you want to connect to your data schema?**, select **Connector**.
4. In **Connector**, enter an expression such as `<+pipeline.variables.connector_name>`, or select **Convert to expression**.
5. In **Repository**, enter a fixed repository name, or an expression such as `<+pipeline.variables.repo_name>`.
6. In **Path to Schema File**, enter a fixed path (for example, `sample.changelog.yaml`), or an expression.
7. If you use an Artifactory connector, enter a fixed path or an expression in **Archive path**.
8. Click **Save**.
   {% endstep %}

{% step %}

### Run a step that uses the schema

Add or open any Database DevOps step that uses this schema, then run the pipeline.

Harness resolves the expressions, clones the changelog with the resolved Git connector and repository, and continues the step.
{% endstep %}
{% endstepper %}

***

## Examples

### Different Git connector per environment

Set the schema **Connector** to:

```
<+pipeline.variables.connector_name>
```

Keep **Repository** and **Path to Schema File** fixed if only the connector changes between environments.

In each stage, set `connector_name` to the connector that can reach that environment's Git host.

### Connector and repository from variables

Set both fields on the schema:

```
Connector:   <+pipeline.variables.connector_name>
Repository:  <+pipeline.variables.repo_name>
```

Provide both values as pipeline variables, or as runtime inputs when you run the pipeline.

***

## Next steps

* [Create a pipeline in Database DevOps](https://developer.harness.io/database-devops/use-db-devops/deployment-pipeline-configuration/create-a-pipeline.md): Build the pipeline that supplies the variables.
* [Apply DB Schema step](https://developer.harness.io/database-devops/use-db-devops/deployment-pipeline-configuration/step-types/apply-dbschema-step.md): Deploy the schema after the expressions resolve.

{% @harness-feedback/feedback %}
