Refs #67 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
26 lines
1.2 KiB
SQL
26 lines
1.2 KiB
SQL
-- +goose Up
|
|
-- Legal notice and privacy policy, either as Markdown served by us or as a
|
|
-- link to a page elsewhere; a link wins when both are set. Rows without an
|
|
-- organization belong to the platform: the console and status pages of
|
|
-- organizations without their own.
|
|
CREATE TABLE legal_documents (
|
|
org_id uuid REFERENCES orgs (id) ON DELETE CASCADE,
|
|
kind text NOT NULL CHECK (kind IN ('imprint', 'privacy')),
|
|
url text NOT NULL DEFAULT '' CHECK (length(url) <= 2000),
|
|
markdown text NOT NULL DEFAULT '' CHECK (length(markdown) <= 100000),
|
|
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
UNIQUE NULLS NOT DISTINCT (org_id, kind)
|
|
);
|
|
|
|
ALTER TABLE legal_documents ENABLE ROW LEVEL SECURITY;
|
|
ALTER TABLE legal_documents FORCE ROW LEVEL SECURITY;
|
|
-- Platform documents are public.
|
|
CREATE POLICY legal_documents_read ON legal_documents FOR SELECT
|
|
USING (app_scope_system() OR org_id IS NULL OR org_id = app_org_id());
|
|
CREATE POLICY legal_documents_write ON legal_documents FOR ALL
|
|
USING (app_scope_system() OR org_id = app_org_id())
|
|
WITH CHECK (app_scope_system() OR org_id = app_org_id());
|
|
|
|
-- +goose Down
|
|
DROP TABLE legal_documents;
|