Skip to content

Add Supabase hosting assets and database bootstrap - #4

Open
eyshoit-commits wants to merge 1 commit into
mainfrom
codex/create-supabase-postgresql-setup-guide
Open

Add Supabase hosting assets and database bootstrap#4
eyshoit-commits wants to merge 1 commit into
mainfrom
codex/create-supabase-postgresql-setup-guide

Conversation

@eyshoit-commits

Copy link
Copy Markdown
Owner

Summary

  • add comprehensive Supabase/Postgres setup, deployment, quick-start, and file index documentation
  • provide environment template and SQL bootstrap covering schemas, policies, and RPC helpers
  • implement Supabase client utility with auth, project, telemetry, and analytics helpers

Testing

  • not run

https://chatgpt.com/codex/tasks/task_e_68f56c8caedc8329acbc2d5de9e0a053

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread database/init.sql
Comment on lines +304 to +335
-- Basic policies for Supabase row-level security (RLS) ----------------------
ALTER TABLE platform.users ENABLE ROW LEVEL SECURITY;
ALTER TABLE platform.projects ENABLE ROW LEVEL SECURITY;
ALTER TABLE platform.sessions ENABLE ROW LEVEL SECURITY;
ALTER TABLE platform.token_usage ENABLE ROW LEVEL SECURITY;
ALTER TABLE platform.api_keys ENABLE ROW LEVEL SECURITY;

CREATE POLICY users_self_access ON platform.users
USING (auth.uid() = id)
WITH CHECK (auth.uid() = id);

CREATE POLICY projects_owner_access ON platform.projects
USING (auth.uid() = owner_id)
WITH CHECK (auth.uid() = owner_id);

CREATE POLICY sessions_owner_access ON platform.sessions
USING (auth.uid() = user_id)
WITH CHECK (auth.uid() = user_id);

CREATE POLICY token_usage_owner_access ON platform.token_usage
USING (auth.uid() = user_id);

CREATE POLICY api_keys_owner_access ON platform.api_keys
USING (auth.uid() = user_id)
WITH CHECK (auth.uid() = user_id);

-- Privileges for service role ------------------------------------------------
GRANT USAGE ON SCHEMA platform, telemetry, analytics TO postgres;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA platform TO postgres;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA telemetry TO postgres;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA analytics TO postgres;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA platform TO postgres;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Grant platform privileges to Supabase client roles

The bootstrap script enables RLS and defines policies but only grants schema/table privileges to the postgres service role. Supabase clients use the anon/authenticated roles when calling the new supabaseClient helpers; without explicit GRANT USAGE/SELECT/INSERT/UPDATE on the platform, telemetry, and analytics schemas and tables, every call such as listProjects or upsertProfile will fail with permission denied even if the RLS policy would allow it. You need to grant the necessary privileges to the client roles (and restrict sensitive functions) so the app can actually read/write data.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant