Skip to content

feat(consent): add the user_consents table with immutability triggers - #1911

Draft
rohanchkrabrty wants to merge 1 commit into
feature/choreproto-pull-flowintent-and-the-consent-document-rpcfrom
feature/featconsent-add-the-user_consents-table-with-immutability
Draft

feat(consent): add the user_consents table with immutability triggers#1911
rohanchkrabrty wants to merge 1 commit into
feature/choreproto-pull-flowintent-and-the-consent-document-rpcfrom
feature/featconsent-add-the-user_consents-table-with-immutability

Conversation

@rohanchkrabrty

@rohanchkrabrty rohanchkrabrty commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds the user_consents table from RFC 0002: Explicit consent at signup, Storage: one row per consent act, with the accepted documents copied into a documents JSONB array at write time so a record stays readable after the document leaves config.
  • Records are immutable. BEFORE UPDATE and BEFORE DELETE triggers both raise 45000, following 20250904105226_add_audit_records_immutability.up.sql — which guards UPDATE only. DELETE is guarded here as well, because a deleted record leaves a user who looks like they never consented.
  • Four choices that look like bugs without the RFC: no foreign key to users (a hard DELETE of the account must neither cascade nor be blocked, so user_email is denormalized); ip_address is nullable TEXT not INET, 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.
  • Migration only — no repository, no Go. The repository and the transactional write follow in a later PR of this stack.
  • migrate up and migrate down both run clean; DROP TABLE is unaffected by a row-level trigger.

@rohanchkrabrty rohanchkrabrty self-assigned this Aug 31, 2026
@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview Aug 31, 2026 7:12pm

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

coveralls commented Aug 31, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 33429108048

Coverage remained the same at 49.161%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 40516
Covered Lines: 19918
Line Coverage: 49.16%
Coverage Strength: 15.74 hits per line

💛 - Coveralls

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
rohanchkrabrty force-pushed the feature/featconsent-add-the-user_consents-table-with-immutability branch from 01f762c to 4c55c3c Compare August 31, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants