Repository navigation
fix(db): scope the service-role write policies to service_role - #1336
Merged
Merged
Conversation
The insert and delete policies the server's writes were written for on prompt_results, prompt_result_citations, prompt_result_shopping_cards, signals, ai_traffic_logs and citation_urls were created without a role. 00235 scopes them to service_role; service_role bypasses row security, so the server's writes are unchanged. Applied on production. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
5 of 12 tasks
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.
Summary
Only the server (with the service role) writes these tables:
prompt_resultsprompt_result_citationsprompt_result_shopping_cardssignalsai_traffic_logscitation_urlsTheir "Service role can insert / delete …" policies were created without a role. Migration 00235 scopes the ten policies to
service_rolewithalter policy … to service_role. The service role bypasses row security, so the server's writes don't change. Members' reads go through the select policies, which aren't touched.Every writer in
server/usessupabaseAdmin. Inweb/, no code inserts into or deletes from these tables. The two SQL functions that do,delete_brand_results_batchandcitation_url_ids, are service-role only.It's applied on the hosted DB. Checked there in rolled-back transactions:
anonis refused by row security;Related issue
None.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) — web not touchedyarn typecheckpasses (run fromweb/) — web not touchedyarn format:checkpasses (run fromweb/) — web not touchedschema.sqlis rebuilt withbuild-schema.sh. SQL only.🤖 Generated with Claude Code
https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A