feat: database schema, RLS policies, and sign-up trigger (#23)#34
Merged
Conversation
Co-authored-by: Ona <no-reply@ona.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
Author
|
Review: ✅ Approved Schema, RLS policies, triggers, and TypeScript types all look correct. Checked:
No blocking issues found. |
Collaborator
Author
|
✅ UI verification skipped — no UI files changed (no |
Collaborator
Author
|
❌ Post-merge verification failed. See #36. Smoke test results:
Failure: The Supabase database connection is failing in production. The health endpoint's |
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.
Closes #23
What
Creates the foundational database schema for Memo — all five tables, Row Level Security policies, and database triggers needed before any feature work can begin.
How
Single migration (
supabase/migrations/20260415092907_create_schema.sql) containing:Tables:
profiles,workspaces,members,workspace_invites,pages— matching the data model indocs/product-spec.md.Custom enums:
member_role(owner/admin/member),invite_role(admin/member).RLS policies on all tables:
profiles— users read own + co-members' profiles, update ownworkspaces— members read, authenticated create (own), admins update, admins delete (non-personal only)members— members read, admins manageworkspace_invites— admins manage, invited users read own by emailpages— members full CRUD (insert requirescreated_by = auth.uid())Helper functions:
is_workspace_member(ws_id)andis_workspace_admin(ws_id)—security definerSQL functions used by RLS policies to check membership.Triggers:
handle_new_user— fires onauth.usersinsert, atomically creates profile + personal workspace (is_personal = true, name = "{display_name}'s Workspace") + owner membershipenforce_workspace_limit—BEFORE INSERTon workspaces, raises exception if user already has 3 workspacesupdate_updated_at— auto-updatesupdated_aton workspaces and pagesTypeScript types in
src/lib/types.tsmatching all database entities.Testing
pnpm lint✅pnpm typecheck✅pnpm test✅ (no test files — this is a schema-only change)npx supabase db lint— cannot run without local Supabase instance; will be validated on deployAcceptance Criteria
profilestable with correct columns and FK to auth.usersworkspacestable withis_personal,created_byFK, partial unique indexmemberstable with role enum, unique constraint on (workspace_id, user_id)workspace_invitestable with token, expiry, accepted_atpagestable with parent_id self-reference, content jsonb, position integerhandle_new_usertrigger creates profile + personal workspace + owner membershipis_personal = falsenpx supabase db lint— requires local instance, deferred to deploy