You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To mirror the setup of the source database in the target database, we need to obtain a schema dump of the source database. You can use `pg_dump` to create a schema-only dump of your source PostgreSQL database:
Before applying this to the target database, we need to remove UNIQUE constraints and indexes from the dump file so that PeerDB's ingestion to target tables is not blocked by these constraints. These can be removed using:
sed -i.bak -E '/CREATE UNIQUE INDEX/,/;/d; /(CONSTRAINT.*UNIQUE|ADD CONSTRAINT.*UNIQUE)/d'<dump_file_path>
66
+
```
67
+
68
+
### Apply schema dump to target database {#migration-peerdb-apply-schema-dump}
69
+
After cleaning up the schema dump file, you can apply it to your target ClickHouse Managed Postgres database by [connecting](../connection) via `psql` and running the schema dump file:
Here on the target side, we do not want PeerDB ingestion to be blocked by foreign key constraints. For this, we can alter the target role (used above in the target peer) to have `session_replication_role` set to `replica`:
75
+
```sql
76
+
ALTER ROLE <target_role>SET session_replication_role = replica;
77
+
```
78
+
50
79
## Create a mirror {#migration-peerdb-create-mirror}
51
80
Next, we need to create a mirror to define the data migration process between the source and target peers. In PeerDB UI, navigate to the "Mirrors" section by clicking on "Mirrors" in the sidebar. To create a new mirror, click on the `+ New mirror` button.
1. Give your mirror a name that describes the migration.
54
83
2. Select the source and target peers you created earlier from the dropdown menus.
55
-
3. You may choose to enable continuous replication if you want to keep the target database in sync with the source after the initial migration. Otherwise, under **Advanced settings**, you can enable **Initial copy only** to perform a one-time migration.
84
+
3. Make sure that:
85
+
- Soft delete is OFF.
86
+
- Expand `Advanced settings`. Make sure that the **Postgres type system is enabled** and **PeerDB columns are disabled**.
Make sure the destination table names are the same as the source table names in the target database, as we have migrated the schema as is in the earlier step.
93
+
:::
94
+
58
95
5. Once you have configured the mirror settings, click on the `Create mirror` button.
59
96
60
97
You should see your newly created mirror in the "Mirrors" section.
0 commit comments