Unlock this content

Enter your email to unlock this content for free

By continuing, you agree to our Terms of Service and Privacy Notice, and to receive occasional marketing emails.

Migration Patterns

TL;DR

Common migration patterns for safely evolving ClickHouse schemas include expand and contract (for renames and type changes), branch + exchange (for full rewrites), and versioning + canary (for testing in production). These patterns help you safely execute schema changes while maintaining system availability and data consistency.

Expand and Contract

The expand and contract pattern is a safe way to rename columns or change data types. You add a new column with the desired name or type, update ingestion to write to both columns, validate the change, and then drop the old column.

Phase 1: Expand (Add New Column)

ALTER TABLE events ADD COLUMN new_column_name NewDataType DEFAULT defaultValue;

Phase 2: Migrate (Write to Both)

-- Update ingestion to write to both columns

Tinybird is not affiliated with, associated with, or sponsored by ClickHouse, Inc. ClickHouse® is a registered trademark of ClickHouse, Inc.

Migration Patterns | ClickHouse for Developers