User input validation is under active development. As we progress we will update this documentation.
Immutable Primary Keys
Electric rejects updates to a table's primary keys.
In order to maintain referential integrity and track changes from connected clients, Electric requires all primary keys to be treated as immutable. An attempt to synchronise a client where a primary key has been changed will be rejected by the server and the offending client will be forcibly disconnected.
CREATE TABLE items (
id uuid PRIMARY KEY,
items (id, value)
('f2ece325-219f-40e2-b5b1-fdb32e32f0ed', 'my first value');
-- don't do this!
id = 'cfe89786-8170-4438-b667-b7874eb5c54c'
id = 'f2ece325-219f-40e2-b5b1-fdb32e32f0ed';
This will leave the client in an inconsistent state and unable to sync until the local database has been reset.
Currently this validation is only applied by the sync service, but in future there will also be client-side validation.