Skip to content

Commit c62b207

Browse files
committed
README revisions based on 1.0 feedback from Noah Yetter
1 parent 86f1ede commit c62b207

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ Tables on the provider and subscriber must have the same columns, with the same
4848
data types in each column. `CHECK` constraints, `NOT NULL` constraints, etc must
4949
be the same or weaker (more permissive) on the subscriber than the provider.
5050

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.
5258

5359
Some additional requirements are covered in "Limitations and Restrictions", below.
5460

@@ -94,8 +100,12 @@ Add all tables in `public` schema to the `default` replication set.
94100
SELECT pglogical.replication_set_add_all_tables('default', ARRAY['public']);
95101

96102
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.
99109

100110
Once the provider node is setup, subscribers can be subscribed to it. First the
101111
subscriber node must be created:
@@ -393,6 +403,19 @@ unique identifier.
393403

394404
See http://www.postgresql.org/docs/current/static/sql-altertable.html#SQL-CREATETABLE-REPLICA-IDENTITY for details on replica identity.
395405

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+
396419
### DDL
397420

398421
Automatic DDL replication is not supported. Managing DDL so that the provider and

0 commit comments

Comments
 (0)