feat(consent): add the user_consents table with immutability triggers - #1911
Draft
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report for CI Build 33429108048Coverage remained the same at 49.161%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
rohanchkrabrty
marked this pull request as draft
August 31, 2026 10:36
This was referenced Aug 31, 2026
Adds user_consents per the RFC's Storage section: the table, the documents_not_empty CHECK, the partial unique index giving a user at most one signup consent, and BEFORE UPDATE / BEFORE DELETE triggers that both raise 45000. Schema only. The repository and the write path land with their caller, following audit_records, whose table migration shipped in #1118 and whose repository followed in #1124. Four choices are deliberate and read as mistakes without the RFC: no foreign key to users, ip_address as nullable TEXT rather than INET, document versions and URLs copied rather than referenced, and the partial unique index. Each is commented in the migration itself. Part of RFC 0002: https://github.com/raystack/frontier/blob/main/docs/rfcs/0002-explicit-consent-at-signup.md Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VW3nysiE4H83VQk6BroMYc
rohanchkrabrty
force-pushed
the
feature/featconsent-add-the-user_consents-table-with-immutability
branch
from
August 31, 2026 19:10
01f762c to
4c55c3c
Compare
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
user_consentstable from RFC 0002: Explicit consent at signup, Storage: one row per consent act, with the accepted documents copied into adocumentsJSONB array at write time so a record stays readable after the document leaves config.BEFORE UPDATEandBEFORE DELETEtriggers both raise45000, following20250904105226_add_audit_records_immutability.up.sql— which guardsUPDATEonly.DELETEis guarded here as well, because a deleted record leaves a user who looks like they never consented.users(a hardDELETEof the account must neither cascade nor be blocked, souser_emailis denormalized);ip_addressis nullableTEXTnotINET, since it comes from a request header and a bad one must not fail a signup; versions and URLs are copies, not references; and a partial unique index on(user_id) WHERE source = 'signup'makes a second signup write fail rather than leave two rows disagreeing.migrate upandmigrate downboth run clean;DROP TABLEis unaffected by a row-level trigger.