brendmanager/migrations/001_init.sql
Peppa 8d43814996
Some checks failed
peppa/install install: failure за 0с
ci / checks (pull_request) Failing after 3s
deploy / deploy (pull_request) Failing after 14s
BRM-10: сервис Knowledge Base, согласования A/B/C, аудит, деплой-конфиг
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 14:02:05 +05:00

102 lines
3.0 KiB
SQL

create type fact_status as enum ('public_confirmed', 'internal_confirmed', 'hypothesis', 'outdated', 'forbidden');
create table source_evidence (
id serial primary key,
title text not null,
url text,
note text,
status fact_status not null default 'hypothesis',
confidence int check (confidence between 0 and 100),
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create table person_profile (
id serial primary key,
full_name text not null,
headline text,
bio text,
status fact_status not null default 'hypothesis',
confidence int check (confidence between 0 and 100),
source_evidence_id int references source_evidence(id),
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create table career_history (
id serial primary key,
organization text not null,
position text,
start_year int,
end_year int,
is_current boolean not null default false,
status fact_status not null default 'hypothesis',
confidence int check (confidence between 0 and 100),
source_evidence_id int references source_evidence(id),
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create table credentials (
id serial primary key,
title text not null,
issuer text,
year int,
document_url text,
status fact_status not null default 'hypothesis',
confidence int check (confidence between 0 and 100),
source_evidence_id int references source_evidence(id),
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create table cases (
id serial primary key,
title text not null,
problem text,
role text,
solution text,
scale text,
result text,
metrics text,
public_use_permitted boolean not null default false,
status fact_status not null default 'hypothesis',
confidence int check (confidence between 0 and 100),
source_evidence_id int references source_evidence(id),
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create table action_policy (
action text primary key,
mode char(1) not null check (mode in ('A', 'B', 'C')),
granted boolean not null default false
);
create table approvals (
id serial primary key,
action text not null references action_policy(action),
status text not null default 'pending' check (status in ('pending', 'approved', 'rejected', 'used')),
payload jsonb,
requested_at timestamptz not null default now(),
decided_at timestamptz
);
create table audit_logs (
id serial primary key,
actor text not null,
action text not null,
entity text not null,
before jsonb,
after jsonb,
created_at timestamptz not null default now()
);
insert into action_policy (action, mode) values
('create_hypothesis', 'A'),
('schedule_approved_content', 'B'),
('set_public_positioning', 'C'),
('publish_sensitive_case', 'C'),
('send_commercial_offer', 'C'),
('send_personal_letter', 'C');