Prerequisites
- Access to your source PostgreSQL database with a user that has replication privileges. Follow the setup guide for your source:
- Amazon RDS Postgres
- Amazon Aurora Postgres
- Supabase Postgres
- Google Cloud SQL Postgres
- Azure Flexible Server for Postgres
- Neon Postgres
- Crunchy Bridge Postgres
- TimescaleDB
- Generic Postgres Source for any other provider or self-hosted instance
- A ClickHouse Managed Postgres service as the migration target. If you don’t have one yet, see the quickstart.
pg_dumpandpsqlinstalled on your local machine. Both ship with the standard PostgreSQL client tools.
Considerations before migrating
- DDL propagation: continuous replication (CDC) captures DML operations and
ADD COLUMN. Other DDL changes such asDROP COLUMNandALTER COLUMNaren’t propagated and must be applied manually on the target.
If you run into issues during migration, check the Managed Postgres Migrations FAQ for common errors and solutions.
Step 1: Connect to your source database
Open the ClickHouse Cloud console and select your Managed Postgres service. In the left sidebar, click Data sources. Click Start import. Fill in the connection details for your source PostgreSQL database: host, port, username, password, and database name. Enable TLS if your source requires it. If you require a private connection to your source database, you can opt for SSH tunneling and provide the necessary SSH details. This allows the migration to securely connect to databases that aren’t publicly accessible. Choose an ingestion method:- Initial load + CDC — copies existing data, then keeps the target in sync with ongoing changes.
- Initial load only — one-time copy, no ongoing replication.
- CDC only — skips the initial copy and replicates only new changes from this point forward.
Automated schema migration
When this option is opted for, the ClickPipe will automatically pull the schema of your source database and apply it to your Managed Postgres service, during the Setup phase of the ClickPipe after it is created. This feature assumes an empty target database, as it pulls every database object from the source database regardless of what tables you select later in the wizard. If you already have existing data in your target database, or are aiming for a more customized setup, you must opt for the Manual mode instead. Select the destination database from the dropdown, or click Create a new database to provision one.Monitoring
You can track the progress of the schema migration in the ClickPipes detail view. The Logs will indicate the status of the schema migration, and any errors encountered will be displayed there as well. This mode has the following limitations:- Pipes using SSH tunneling cannot use automated schema migration. The schema must be exported and imported manually.
Manual schema migration
For cases where you already have existing data in your target database, or are aiming for a more customized setup versus the clean slate which the automated mode expects, you can opt for the Manual mode here.Export your database schema
The wizard displays apg_dump command pre-filled with your source connection details. Run it in a terminal:
pg.sql in your current directory.
Click Next.
Import the schema into your Managed Postgres service
Select the destination database from the dropdown, or click Create a new database to provision one. The wizard displays apsql command to apply the schema dump to your Managed Postgres service. Run it in a terminal:
Step 4: Configure ingestion settings
Specify the publication to use for logical replication. If you leave this blank, a publication is created automatically. Expand Advanced replication settings to tune throughput:
Click Next.