What you’ll need
- A PostgreSQL table with no primary key
- An existing unique index, or columns that you can make unique, to identify each row
- Permission to alter the source table’s replica identity
Configure the table
1
Create or identify a unique index
Artie requires the override columns to match a unique index on the source table. If you want to turn an existing column into an actual unique constraint, first run this check. It must return no rows:Then run the following outside a transaction block. The index build does not block inserts, updates, or deletes. The final For a composite identifier, create one unique index containing all of the columns you will select in Artie.
ALTER TABLE is brief and fails after five seconds rather than waiting on a conflicting lock.2
Set the table replica identity to FULL
Run the following as the table owner or another role with permission to alter the table:
REPLICA IDENTITY FULL makes PostgreSQL include the full previous row in update and delete events, which lets Artie use the override columns when the table has no primary key.This setting can increase WAL volume for updates and deletes because PostgreSQL records the full old row. Monitor replication-slot usage after enabling it.
3
Add the table and set the primary key override in Artie
In the Artie dashboard, open your pipeline, then go to Edit > Tables. Add or select the table, open Table settings, and choose the Advanced settings tab.Enable Override primary keys and select the column or columns from the unique index. For the example above, select
external_id.Keep the selected columns included in replication. Artie uses them as the table’s merge key in the destination.4
Save, deploy, and verify
Save the table settings and deploy the pipeline. Verify an insert, update, and delete on the source table are reflected in the destination.