> ## Documentation Index
> Fetch the complete documentation index at: https://docs.paradime.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Turbo CI for dbt™ pull requests

> Turbo CI runs and tests only your changed dbt™ models on each pull request in a temporary schema, on GitHub, GitLab, Azure DevOps, or BitBucket.

Turbo CI runs and tests only your changed dbt™ models on every pull request, before they merge. When a PR is opened, your CI provider triggers a Turbo CI Bolt schedule that builds and tests the changes in a temporary schema, and the run status shows on the pull request. Turbo CI works with [GitHub](/products/bolt/ci-cd/turbo-ci/github), [GitLab](/products/bolt/ci-cd/turbo-ci/gitlab), [Azure DevOps](/products/bolt/ci-cd/turbo-ci/azure-devops), and [BitBucket](/products/bolt/ci-cd/turbo-ci/bitbucket).

## How Turbo CI works

When a pull request is opened, your CI provider triggers a Turbo CI schedule in Paradime, which runs your configured dbt™ command against the changed models. Models build into a temporary schema using the prefix `paradime_turbo_ci_pr_` followed by the commit SHA (for example, `paradime_turbo_ci_pr_6d8f55c0`), so you can inspect the results of your changes in your warehouse.

## Prerequisites

Turbo CI runs in its own Bolt environment, so CI builds use a separate warehouse connection and target from your production runs:

1. **Create a CI environment.** In **Settings > Environments**, click **New environment** and create one for CI (for example, `CI`). See [Create and manage environments](/products/settings/connections/index#create-and-manage-environments).
2. **Add a connection to it.** Attach a warehouse connection to the CI environment with its **target name** set to `ci`. See the [Bolt environment setup guide](/products/settings/connections/scheduler-environment/index) for your data warehouse.
3. **Point the Turbo CI schedule at it.** Set the schedule's **Environment** to the CI environment in [schedule settings](/products/bolt/creating-schedules/schedule-settings), or set `environment: <ci-environment-slug>` in the schedule's YAML.

<Warning>
  Without a dedicated CI environment, Turbo CI runs would use your default environment's connection and target, so the `ci` target logic in the schema macro below would never engage.
</Warning>

<Card title="Already running Turbo CI with --target ci?" icon="arrow-right" href="/guides/migrations/migrate-turbo-ci-to-a-dedicated-environment" horizontal>
  Follow the migration guide to move to a dedicated CI environment and drop the `--target ci` flags from your commands.
</Card>

## Configure a custom schema for CI runs

Update your dbt™ `generate_schema_name.sql` macro so that, when a Bolt run uses the `ci` target, models build into a temporary schema with the `paradime_turbo_ci_pr` prefix. In your project's *macros* folder, create `generate_schema_name.sql`:

```sql theme={"system"}
{% macro generate_schema_name(custom_schema_name, node) -%}

    {%- set default_schema = target.schema -%}
    {%- if target.name == 'prod' -%}

        {{ custom_schema_name | trim }}

    {%- elif target.name == 'ci' -%}

        {{ default_schema }}

    {%- else -%}

        {%- if custom_schema_name is none -%}

            {{ default_schema }}

        {%- else -%}

            {{ default_schema }}_{{ custom_schema_name | trim }}

        {%- endif -%}

    {%- endif -%}

{%- endmacro %}
```

See the [dbt custom schemas documentation](https://docs.getdbt.com/docs/build/custom-schemas#advanced-custom-schema-configuration).

## Configure the Turbo CI job

A Turbo CI job is a Bolt schedule with a few additions:

* Its **environment** set to your CI environment, so runs use the CI connection and `ci` target.
* A production schedule to **defer** to, so [state comparison](/products/bolt/ci-cd/index#deferral-and-state-comparison) can determine what changed.
* `commands` that use the `state:modified+` selector to build and test only new and changed models.
* A trigger set to run when a pull request is opened.

<Card title="Test Code Changes On Pull Requests" href="/products/bolt/creating-schedules/templates/ci-cd-templates/test-code-changes-on-pull-requests" horizontal icon="arrow-right" />

## Set up your CI pipeline

Once the shared setup above is in place, wire up Turbo CI in your provider:

<CardGroup cols={2}>
  <Card title="GitHub" href="/products/bolt/ci-cd/turbo-ci/github" horizontal />

  <Card title="GitLab" href="/products/bolt/ci-cd/turbo-ci/gitlab" horizontal />

  <Card title="Azure DevOps" href="/products/bolt/ci-cd/turbo-ci/azure-devops" horizontal />

  <Card title="BitBucket" href="/products/bolt/ci-cd/turbo-ci/bitbucket" horizontal />
</CardGroup>


## Related topics

- [Turbo CI on BitBucket pull requests](/products/bolt/ci-cd/turbo-ci/bitbucket.md)
- [Turbo CI on GitHub pull requests](/products/bolt/ci-cd/turbo-ci/github.md)
- [Turbo CI on Azure DevOps pull requests](/products/bolt/ci-cd/turbo-ci/azure-devops.md)
- [Bolt CI/CD for dbt™ pull requests and deploys](/products/bolt/ci-cd/index.md)
- [Turbo CI Schema Cleanup macro for dbt™](/products/bolt/ci-cd/turbo-ci/paradime-turbo-ci-schema-cleanup.md)
