electric-sql / electric

Sync little subsets of your Postgres data into local apps and services.
https://electric-sql.com
Apache License 2.0
6.2k stars 146 forks source link

Manage mutation of permissions directly in the proxy #1393

Closed magnetised closed 1 month ago

magnetised commented 3 months ago

Rather than send ddlx commands through the replication stream and then apply them to the current permissions state when they come out of pg, this pr instead moves mutation of the permissions to the proxy process. so we load the current permissions state within the proxy transaction then mutate them on receipt of any ddlx commands.

if at the end of the tx the perms have changed, then we write them to pg before committing the txn.

the advantage of this is that the proxy is able to retrieve a consistent view of the permissions within migration transactions and so can determine the permissions state for any table when updating triggers. basically an essential building block if we're going to defer adding the consistency triggers at the point of granting write perms.

also includes a re-factor of the way we keep track of published tables to hopefully make that process less error prone, and a bit of a clean up of the internal migration code.

KyleAMathews commented 1 month ago

👋 we've been working the last month on a rebuild of the Electric server over at a temporary repo https://github.com/electric-sql/electric-next/

You can read more about why we made the decision at https://next.electric-sql.com/about

We're really excited about all the new possibilities the new server brings and we hope you'll check it out soon and give us your feedback.

We're now moving the temporary repo back here. As part of that migration we're closing all the old issues and PRs. We really appreciate you taking the time to investigate and create this improvement!