@@ -48,7 +48,13 @@ Tables on the provider and subscriber must have the same columns, with the same
48
48
data types in each column. ` CHECK ` constraints, ` NOT NULL ` constraints, etc must
49
49
be the same or weaker (more permissive) on the subscriber than the provider.
50
50
51
- Tables must have the same Primary Keys and be related by the same Foreign Keys.
51
+ Tables must have the same ` PRIMARY KEY ` s. It is not recommended to add additional
52
+ ` UNIQUE ` constraints other than the ` PRIMARY KEY ` (see below).
53
+
54
+ Any ` FOREIGN KEY ` s on the subscriber must also be present on the provider with
55
+ all rows on the subscriber present on the provider. In other words a
56
+ subscriber's FK constraints must always permit a write if the provider's FK
57
+ constraints permitted it.
52
58
53
59
Some additional requirements are covered in "Limitations and Restrictions", below.
54
60
@@ -94,8 +100,12 @@ Add all tables in `public` schema to the `default` replication set.
94
100
SELECT pglogical.replication_set_add_all_tables('default', ARRAY['public']);
95
101
96
102
Optionally you can also create additional replication sets and add tables to
97
- them (see [ Replication sets] ( #replication-sets ) ). It's usually better to create
98
- replication sets beforehand.
103
+ them (see [ Replication sets] ( #replication-sets ) ).
104
+
105
+ It's usually better to create replication sets before subscribing so that all
106
+ tables are synchronized during initial replication setup in a single initial
107
+ transaction. However, users of bigger databases may instead wish to create them
108
+ incrementally for better control.
99
109
100
110
Once the provider node is setup, subscribers can be subscribed to it. First the
101
111
subscriber node must be created:
@@ -393,6 +403,19 @@ unique identifier.
393
403
394
404
See http://www.postgresql.org/docs/current/static/sql-altertable.html#SQL-CREATETABLE-REPLICA-IDENTITY for details on replica identity.
395
405
406
+ ### Only one unique index/constraint/PK
407
+
408
+ If more than one upstream is configured or the downstream accepts local writes
409
+ then only one ` UNIQUE ` index should be present on downstream replicated tables.
410
+ Conflict resolution can only use one index at a time so conflicting rows may
411
+ ` ERROR ` if a row satisfies the ` PRIMARY KEY ` but violates a ` UNIQUE ` constraint
412
+ on on the downstream side. This will stop replication until the downstream table
413
+ is modified to remove the violation.
414
+
415
+ It's fine to have extra unique constraints on an upstream if the downstream only
416
+ gets writes from that upstream and nowhere else. The rule is that the downstream
417
+ constraints must * not be more restrictive* than those on the upstream(s).
418
+
396
419
### DDL
397
420
398
421
Automatic DDL replication is not supported. Managing DDL so that the provider and
0 commit comments