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

# PostgreSQL to PostgreSQL

> A complete example using the current tabbed pipeline workspace.

This example moves `public.orders` into `analytics.orders_live`.

## 1. Prepare the destination

Create `analytics.orders_live` before delivery. Its columns must match the
published SQL output, and `id` should be its primary key for Upsert.

## 2. Create connections and pipeline

Create/test a PostgreSQL source with read access to `public.orders` and a
PostgreSQL destination with write access to `analytics.orders_live`. Then create
`Orders to Analytics` from **Data Pipelines** and open it.

## 3. Configure Source

1. Open **Source**.
2. Click **Discover catalog**.
3. Enable `public.orders` and keep **Full table** for the first run.
4. Preview rows and click **Save stream settings**.

## 4. Add the destination

1. Open **Destinations** and click **Add destination**.
2. Select the PostgreSQL connection and set the target schema to `analytics`.
3. Save the destination.

## 5. Create and publish SQL

Open **Transformations**, select the destination, and create a transformation
using `public.orders` as input:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT
  id,
  customer_id,
  order_status,
  total_amount,
  created_at,
  updated_at
FROM {{ source('raw', 'public__orders') }}
WHERE order_status IS NOT NULL
```

Click **Save draft**, **Validate draft**, **Preview output**, and **Publish revision**.

## 6. Assign destination output

Open the destination editor. Under **Published output targets**, enter
`analytics.orders_live`, use `id` as the Upsert key, create/verify the table if
needed, and save.

## 7. Run and verify

Open **Overview**, click **Validate pipeline**, then click **Run all**. In
**Runs**, confirm success, rows written, the published revision, target
`analytics.orders_live`, and any warnings.

## 8. Move to Incremental

After the Full table run succeeds:

1. Open **Source**.
2. Change `public.orders` to **Incremental**.
3. Enter `updated_at` as the cursor and save stream settings.
4. Run manually again and inspect **Runs**.
5. Add a schedule in **Settings**.
