feat(family): add families schema, RLS, and invite email - #529
Open
plusmobileapps wants to merge 1 commit into
Open
feat(family): add families schema, RLS, and invite email#529plusmobileapps wants to merge 1 commit into
plusmobileapps wants to merge 1 commit into
Conversation
A family is a group of accounts that share content across grocery lists, recipe books, and the meal plan. This adds the group and membership model plus its invite flow; the family_id columns that scope the three domains land in later phases. Families sit alongside the existing per-entity sharing rather than replacing it — nothing here touches grocery_list_members or recipe_book_members, so sharing a single list or book outside the family keeps working. Structure mirrors 20260425_add_collaboration.sql. Three things worth review: - The partial unique index on family_members(user_id) WHERE status='accepted' is what enforces one family per user. Accepting a second invite fails at the DB with 23505 rather than silently corrupting current_family_id(). - The helpers are SECURITY DEFINER because the families and family_members policies check each other's tables and would otherwise recurse (42P17) — the same failure 20260610_fix_recipe_rls_recursion.sql was written to fix. - current_family() exists because families_invitees_select deliberately widens SELECT to families you've only been invited to, so a blanket select() would pull an unjoined family into the client's cache. Same over-fetch shape as #487. notify_invite_email() gains a 'family' kind rather than a second function, so all three invite kinds stay on one code path; the edge function now resolves the parent name and owner through one lookup table. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack 1/3 — backend only. No Kotlin changes, so nothing in the app reads any of this yet.
What
A family is a group of accounts that share content across grocery lists, recipe books, and the meal plan. This is the group + membership model and its invite flow. The
family_idcolumns that actually scope the three domains land in later phases.Families sit alongside the existing per-entity sharing rather than replacing it — nothing here touches
grocery_list_membersorrecipe_book_members, so sharing a single list or book with someone outside your family keeps working.Three things worth a close look
One family per user is enforced by the database, not the client.
Any number of pending invites are fine; accepting a second fails with 23505. That's what lets
current_family_id()return a single unambiguous value for every future policy to compare against.The helpers are
SECURITY DEFINERfor a specific reason. Thefamiliespolicies check membership and thefamily_memberspolicies check family ownership, so without them they'd reference each other's RLS-protected tables and recurse (42P17) — the same failure20260610_fix_recipe_rls_recursion.sqlwas written to fix.current_family()exists because a blanket select would over-fetch.families_invitees_selectdeliberately widens SELECT to families you've only been invited to, so the invite card can show a name. A plainselect()onfamilieswould therefore pull an unjoined family into the client's cache — the same shape as the #487 over-fetch. The client (stack 2/3) goes through the RPC instead.Invite email
notify_invite_email()gains afamilybranch rather than a second function, so all three invite kinds stay on one code path. The edge function now resolves the parent name and owner through one lookup table coveringgrocery_lists/recipe_books/families.No new secrets or Vault setup — it reuses what
20260707_invite_email_notification.sqlalready established.Deploying
Prod's schema is hand-managed and its migration history isn't reconciled with the CLI, so this is written to be idempotent and re-runnable. Worth applying it in the SQL editor and running it a second time to confirm before merging.
🤖 Generated with Claude Code