Start for Free Schedule a Demo

Seamlessly Handling Primary Key Datatype Changes with Hevo

A hands-on walkthrough of how Hevo handles a primary key moving from BIGINT to VARCHAR in PostgreSQL, keeping Snowflake in sync without interrupting replication.

Written by
Rohit Karlupia · Distinguished Engineer
December 3, 2026  ·  5 mins
Seamlessly Handling Primary Key Datatype Changes with Hevo

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 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
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
1SELECT *
2FROM tpch1g.customer_payments
3ORDER BY payment_id;

To inspect the primary-key column's datatype:

PostgreSQL
1SELECT
2 column_name,
3 data_type,
4 character_maximum_length
5FROM information_schema.columns
6WHERE table_schema = 'tpch1g'
7 AND table_name = 'customer_payments'
8 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
1DESC TABLE YOUR_DATABASE.YOUR_SCHEMA.CUSTOMER_PAYMENTS;

Check the existing records:

Snowflake
1SELECT *
2FROM YOUR_DATABASE.YOUR_SCHEMA.CUSTOMER_PAYMENTS
3ORDER 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
1ALTER TABLE tpch1g.customer_payments
2ALTER COLUMN payment_id TYPE VARCHAR(30)
3USING payment_id::VARCHAR(30);

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

Verify the updated source datatype:

PostgreSQL
1SELECT
2 column_name,
3 data_type,
4 character_maximum_length
5FROM information_schema.columns
6WHERE table_schema = 'tpch1g'
7 AND table_name = 'customer_payments'
8 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
1DESC 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
1SELECT *
2FROM YOUR_DATABASE.YOUR_SCHEMA.CUSTOMER_PAYMENTS
3ORDER 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.

Rohit Karlupia
Distinguished Engineer
schema evolutionprimary keypostgresqlsnowflake