[IDENTITY] Create core/vision DB schemas and roles
lint / hygiene (push) Failing after 24s

This commit is contained in:
root committed 2026-11-24 17:14:42 +03:00
1 parent a896debb7c
commit 70908784ed
1 file changed
+90
+90
View File
@@ -0,0 +1,90 @@
-- Identity core/vision schema, 2026-11-24
-- passwords are stored on host, not in repo
create schema if not exists identity authorization core_user;
create table if not exists identity.person (
id uuid primary key default gen_random_uuid(),
display_name text not null,
kind text not null default 'person',
status text not null default 'active',
created_at timestamptz not null default now()
);
create table if not exists identity.account (
id uuid primary key default gen_random_uuid(),
person_id uuid references identity.person(id) on delete set null,
provider text not null,
subject text not null,
email text,
created_at timestamptz not null default now(),
unique (provider, subject)
);
create table if not exists identity.consent (
id uuid primary key default gen_random_uuid(),
person_id uuid not null references identity.person(id) on delete cascade,
purpose text not null,
granted_at timestamptz,
revoked_at timestamptz,
document_ref text
);
create index if not exists person_display_name_idx on identity.person (display_name);
create index if not exists account_person_idx on identity.account (person_id);
create schema if not exists vision authorization vision_user;
create table if not exists vision.model (
id uuid primary key default gen_random_uuid(),
name text not null,
version text not null,
dim integer not null,
active boolean not null default false,
created_at timestamptz not null default now(),
unique (name, version)
);
create table if not exists vision.asset_ref (
id uuid primary key default gen_random_uuid(),
source text not null,
source_id text not null,
kind text not null default 'photo',
captured_at timestamptz,
created_at timestamptz not null default now(),
unique (source, source_id)
);
create table if not exists vision.face (
id uuid primary key default gen_random_uuid(),
asset_ref_id uuid not null references vision.asset_ref(id) on delete cascade,
bbox jsonb not null default '{}'::jsonb,
quality real,
detector_model text,
created_at timestamptz not null default now()
);
create table if not exists vision.embedding (
id uuid primary key default gen_random_uuid(),
face_id uuid not null references vision.face(id) on delete cascade,
model_id uuid not null references vision.model(id),
vector vector(512) not null,
created_at timestamptz not null default now(),
unique (face_id, model_id)
);
create table if not exists vision.match (
id uuid primary key default gen_random_uuid(),
face_id uuid not null references vision.face(id) on delete cascade,
person_id uuid not null,
score real not null,
status text not null default 'suggested',
reviewed_by text,
reviewed_at timestamptz,
created_at timestamptz not null default now(),
check (status in ('suggested','confirmed','rejected'))
);
create index if not exists face_asset_idx on vision.face (asset_ref_id);
create index if not exists match_person_idx on vision.match (person_id);
create index if not exists match_face_idx on vision.match (face_id);
create index if not exists embedding_hnsw on vision.embedding using hnsw (vector vector_cosine_ops);