Closed gorbak25 closed 11 months ago
Hey, thanks for the suggestion!
Electric's scope and logic extend past the PG. What you're suggesting is very similar to, say, CHECK
constraint on column. For that to work well, and keep the client and the server consistent, we need to make the both the client and Electric aware of these checks: the client so that non-malicious users have their write rejected locally and not on the server (since rejecting a write on the server is introducing tentativity or rollback logic, and that's not very local-friendly), and on Electric so that bad data doesn't get into Postgres replication stream.
For your suggestion to work, Electric itself (i.e. Elixir code) needs to be made aware of your domain function, and to be able to execute it on incoming user data. We're working towards that, but that still needs some time.
Hi! In my app the postgres database is append only for everything, due to it we want to use UUIDv7 not UUIDv4. I'm trying to enforce in the data model that everybody uses UUIDv7 not UUIDv4. I've created a domain type based on uuid for that:
Unfortunately electric doesn't consider that a type might be a domain type and that it has a base type:
https://github.com/electric-sql/electric/blob/2b24fa273d9597a3e143f278d756e67221c1d848/components/electric/lib/electric/postgres/extension/functions/validate_table_column_types.sql.eex#L27C20-L27C29 I suggest replacing
with something along the lines of