Conflict Policies

Setting Policies

Conflict policies are set per constraint. When a sync writes to a collection violates a constraint, the policy determines how to handle it:

ALTER COLLECTION notes SET ON CONFLICT LAST_WRITER_WINS FOR UNIQUE;
ALTER COLLECTION profiles SET ON CONFLICT CASCADE_DEFER FOR FOREIGN_KEY;

Available Policies

PolicyBehavior
LAST_WRITER_WINSConcurrent writes to the same field: timestamp-latest wins (default)
RENAME_SUFFIX (alias RENAME_APPEND_SUFFIX)Duplicate key: append suffix to ID and retry insert
CASCADE_DEFERForeign key missing: defer validation until next cascade check
ESCALATE_TO_DLQViolation: move the row to a dead-letter queue for manual review

Per-Collection Configuration

Policies are stored per collection and per constraint type. Each collection can have different policies for UNIQUE, FOREIGN_KEY, and CHECK constraints:

ALTER COLLECTION notes SET ON CONFLICT LAST_WRITER_WINS FOR UNIQUE;
ALTER COLLECTION orders SET ON CONFLICT CASCADE_DEFER FOR FOREIGN_KEY;
SHOW CONFLICT POLICY ON notes;

CUSTOM policies are configured via the native protocol and are not available via SQL DDL.