---
title: Seamlessly Handling Primary Key Datatype Changes with Hevo
description: See how Hevo carries a PostgreSQL primary-key change from BIGINT to VARCHAR(30) into Snowflake, preserving existing data with no pipeline rebuild.
canonical_url: https://hevodata.com/hevo-engineering/seamlessly-handling-primary-key-datatype-changes-with-hevo/
image: https://res.cloudinary.com/hevo/image/upload/v1796318524/hevo-website/etl-tools/phsac2piyrgmmefzhsi5.png
published_at: 2026-12-03T17:19:15.192721+00:00
updated_at: 2026-12-03T20:09:33.860145+00:00
author: Rohit Karlupia
tags: [schema evolution, primary key, postgresql, snowflake]
category: Schema Evolution
content_type: article
word_count: 545
source: https://hevodata.com/hevo-engineering/seamlessly-handling-primary-key-datatype-changes-with-hevo.md
---
# Seamlessly Handling Primary Key Datatype Changes with Hevo

> See how Hevo carries a PostgreSQL primary-key change from BIGINT to VARCHAR(30) into Snowflake, preserving existing data with no pipeline rebuild.

## Adapting to Evolving Source Schemas Without Disrupting Data Replication

As applications evolve, the way they identify records can change too. A payment platform that initially uses numeric transaction IDs may eventually move to alphanumeric identifiers to support new business requirements.

Such changes often involve modifying the datatype of a primary-key column, which can be challenging for data replication pipelines.

**[Hevo](https://hevodata.com/) seamlessly handles primary-key datatype changes, automatically reflecting the updated datatype in the destination while preserving existing data and keeping replication running without interruption.**

Let's walk through a practical example using a PostgreSQL-to-Snowflake pipeline.

## The Scenario: Moving from Numeric to Alphanumeric Payment IDs

Consider a payment platform that initially identifies transactions using numeric IDs, such as `10001` and `10002`.

As the application evolves, the engineering team introduces a new identifier format that supports alphanumeric values, such as `PAY-10007`.

To accommodate this change, the `payment_id` column needs to move from `BIGINT` to `VARCHAR(30)`. Since this column is also the primary key, the change needs to be reflected correctly in the warehouse.

Here's how Hevo handles this transition.

[? Seamlessly Handling Primary Key Datatype Changes with Hevo](https://www.youtube.com/watch?v=41TTt6RxYnU)

_Watch Hevo carry a primary key change from BIGINT to VARCHAR(30) into Snowflake, end to end._

## Step 1: Examine the Existing Source Schema

We begin with the `customer_payments` table in PostgreSQL.

**`PostgreSQL`**

```sql
SELECT *
FROM tpch1g.customer_payments
ORDER BY payment_id;
```

To inspect the primary-key column's datatype:

**`PostgreSQL`**

```sql
SELECT
    column_name,
    data_type,
    character_maximum_length
FROM information_schema.columns
WHERE table_schema = 'tpch1g'
  AND table_name = 'customer_payments'
  AND column_name = 'payment_id';
```

Initially, `payment_id` is defined as `BIGINT` and serves as the table's primary key.

## Step 2: Check the Existing Snowflake Destination

Before making any changes, inspect the corresponding destination table.

**`Snowflake`**

```sql
DESC TABLE YOUR_DATABASE.YOUR_SCHEMA.CUSTOMER_PAYMENTS;
```

Check the existing records:

**`Snowflake`**

```sql
SELECT *
FROM YOUR_DATABASE.YOUR_SCHEMA.CUSTOMER_PAYMENTS
ORDER BY PAYMENT_ID;
```

This establishes the baseline for verifying the schema change and confirming that existing data is retained.

## Step 3: Modify the Primary-Key Datatype in PostgreSQL

The engineering team now changes `payment_id` from `BIGINT` to `VARCHAR(30)`.

**`PostgreSQL`**

```sql
ALTER TABLE tpch1g.customer_payments
ALTER COLUMN payment_id TYPE VARCHAR(30)
USING payment_id::VARCHAR(30);
```

PostgreSQL converts the existing numeric identifiers into strings while retaining the primary-key constraint.

Verify the updated source datatype:

**`PostgreSQL`**

```sql
SELECT
    column_name,
    data_type,
    character_maximum_length
FROM information_schema.columns
WHERE table_schema = 'tpch1g'
  AND table_name = 'customer_payments'
  AND column_name = 'payment_id';
```

The column now has the `VARCHAR(30)` datatype.

## Step 4: Let Hevo Handle the Destination Schema Change

Once the source schema changes, Hevo detects and processes the updated primary-key datatype through the existing pipeline.

Hevo automatically reflects the datatype change in the corresponding Snowflake destination column after the next incremental run. Existing records remain available, and the pipeline continues running without requiring manual destination-side schema modifications or pipeline recreation.

This means data teams can accommodate evolving primary-key definitions without having to rebuild their existing data integration setup.

## Step 5: Verify the Updated Snowflake Schema

After Hevo processes the change, inspect the destination table:

**`Snowflake`**

```sql
DESC TABLE YOUR_DATABASE.YOUR_SCHEMA.CUSTOMER_PAYMENTS;
```

The `PAYMENT_ID` column now reflects the updated `VARCHAR(30)` datatype.

Verify that the existing records are still available:

**`Snowflake`**

```sql
SELECT *
FROM YOUR_DATABASE.YOUR_SCHEMA.CUSTOMER_PAYMENTS
ORDER BY PAYMENT_ID;
```

The original payment records remain intact in Snowflake, with their identifiers represented using the updated datatype.

## Step 6: Confirm Successful Pipeline Execution

Review the pipeline run details and **Job History** in Hevo.

The pipeline completes successfully, with no failed loads or replication interruption during the primary-key datatype change.

## The Takeaway

Primary-key datatype changes don't have to mean pipeline disruptions or manual warehouse maintenance.

With Hevo, changes such as moving a primary key from `BIGINT` to `VARCHAR` are handled automatically. The updated datatype is reflected in Snowflake, existing data is preserved, and replication continues without interruption.

**Hevo helps data teams keep their pipelines running smoothly even as the underlying application data model evolves.**
