PowerSync self-hosting — operator prep on Supabase, sops, and sync rules export #37
Labels
No labels
bug
enhancement
in-progress
needs-info
needs-triage
p0
ready-for-agent
ready-for-human
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/nixos#37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
PowerSync Cloud is being retired for the Cloonar fit app in favour of self-hosting PowerSync Service on
web-arm. The implementation work is fully designed and scoped in a separateready-for-agentissue, but several prerequisites can only be carried out by the operator (Supabase SQL editor access, decryptingsops, retrieving sync rules from the cloonar-fit repo or the Cloud dashboard). The agent's implementation issue is blocked until these artifacts exist.Solution
A checklist of operator-only prep steps. Completing every item produces the inputs the implementation issue needs, after which the operator removes the
blocked byrelationship and the implementation can proceed.User Stories
powersync_selfhostPostgres role on Supabase withLOGINandREPLICATIONattributes and a strong password, so that the self-hosted PowerSync Service can replicate logically from Supabase without sharing credentials with the existing Cloud setup.powersync_selfhostrole grantedSELECTon every table PowerSync syncs (withALTER DEFAULT PRIVILEGEScovering future tables), so that sync rules don't fail at runtime with permission-denied.powersync_selfhostwhose table list mirrors the existing Cloud publication, so that the self-hosted service replicates exactly the same data as Cloud during the parallel-run validation window.sslmode=require) added tohosts/web-arm/secrets.yamlunder the keypowersync-source-dsn, so that the implementation can reference the secret through sops without the agent ever touching secret material.Implementation Decisions
This issue produces operator-only artifacts; no NixOS modules, no code.
pg_publication_tables; create thepowersync_selfhostrole withLOGIN REPLICATIONand a generated strong password; grantUSAGEonpublic,SELECTon all current tables, and matching default privileges for future tables; create publicationpowersync_selfhostfor the audited table list. Do not create the replication slot manually — PowerSync auto-creates it on first connect withslot_name: powersync_selfhostin its config.hosts/web-arm/secrets.yamlvianix-shell -p sops --run 'sops hosts/web-arm/secrets.yaml'and add apowersync-source-dsnentry. Per CLAUDE.md, only the operator edits encrypted files. The value is the full DSN:postgresql://powersync_selfhost:PASSWORD@db.<project>.supabase.co:5432/postgres?sslmode=require.Testing Decisions
Verification, not unit tests. After each prep step:
\du powersync_selfhoston Supabase shows theReplicationattribute.SELECT * FROM pg_publication_tables WHERE pubname = 'powersync_selfhost';lists the expected tables.nix-shell -p sops --run 'sops -d hosts/web-arm/secrets.yaml'decrypts cleanly and shows the new key.psql "<dsn>" -c "SELECT 1;"succeeds. (This confirms the password, the role's LOGIN attribute, andsslmode=requireall line up.)Out of Scope
update.sh, postgres storage role bootstrap, blackbox probe — covered in the linked implementation issue.Further Notes
p0because PowerSync Cloud cost is the motivating concern; the longer this sits, the longer that monthly subscription continues.blocked byreference (or close this issue, which surfaces the dependency in Forgejo's UI). The implementation issue is already labelledready-for-agent; closing this one effectively releases it.Sync rules — operator-supplied artifact for this issue (US#6). #38 copies this byte-for-byte into the NixOS repo at the sync-rules path it configures.
Validation — cross-checked against the
powersync_selfhostpublication: all 14 published tables are referenced, and no table outside the publication is queried. Coverage is 1:1.Operator prep complete — closing
powersync_selfhostrole (LOGIN REPLICATION) + grants (SELECT on all public tables + default privileges for future tables) +powersync_selfhostpublication over the 14 audited tables.reptide-powersync-source-dsnadded tohosts/web-arm/secrets.yaml(onmain). Named with thereptide-prefix to match web-arm's<app>-<purpose>secret convention (cf.fueltide-supabase-db-password); #38's three references were updated to the prefixed key.Note for #38: the DSN targets Supabase's IPv4 pooler (the direct
db.<project>endpoint is IPv6-only).psql … SELECT 1over TLS succeeds, but that does not exercise logical replication — pooler compatibility (a transaction-mode pooler cannot carry the logical-replication protocol) must be confirmed when the service first connects and creates its slot.#38 remains
needs-triagepending re-review.