feat(accounts): add consent settings and organization management
This commit is contained in:
1 parent
24638d46d2
commit
391af7a1ef
83 files changed
+10198
-613
No files matched your search
@@ -0,0 +1,37 @@
|
||||
-- A C1 revocation creates a durable request for the account-deletion workflow.
|
||||
-- The API records the request and its outbox intent atomically; processing and
|
||||
-- deleting the account are separate operations.
|
||||
-- +goose Up
|
||||
CREATE TABLE account_deletion_requests (
|
||||
id uuid NOT NULL,
|
||||
subject_id uuid,
|
||||
status text NOT NULL,
|
||||
requested_at timestamptz NOT NULL,
|
||||
completed_at timestamptz,
|
||||
CONSTRAINT account_deletion_requests_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT account_deletion_requests_subject_id_fkey FOREIGN KEY (subject_id)
|
||||
REFERENCES users (id) ON DELETE SET NULL,
|
||||
CONSTRAINT account_deletion_requests_status_known CHECK (
|
||||
status IN ('requested', 'processing', 'completed')
|
||||
),
|
||||
CONSTRAINT account_deletion_requests_state_shape CHECK (
|
||||
(status = 'completed') = (completed_at IS NOT NULL)
|
||||
),
|
||||
CONSTRAINT account_deletion_requests_subject_retained_until_complete CHECK (
|
||||
subject_id IS NOT NULL OR status = 'completed'
|
||||
),
|
||||
CONSTRAINT account_deletion_requests_completed_after_request CHECK (
|
||||
completed_at IS NULL OR completed_at >= requested_at
|
||||
)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX account_deletion_requests_one_active_per_subject
|
||||
ON account_deletion_requests (subject_id)
|
||||
WHERE subject_id IS NOT NULL AND status IN ('requested', 'processing');
|
||||
|
||||
CREATE INDEX account_deletion_requests_processing_idx
|
||||
ON account_deletion_requests (requested_at, id)
|
||||
WHERE status IN ('requested', 'processing');
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE account_deletion_requests;
|
||||
Reference in new issue
Block a user