This repository has no description
1-- Repo ↔ collaborator edges (from knot sh.tangled.repo.listCollaborators).
2
3create table if not exists public.tangled_repo_collaborators (
4 repo_did text not null,
5 collaborator_did text not null,
6 added_by text,
7 record_uri text,
8 record_cid text,
9 created_at timestamptz,
10 first_seen_at timestamptz not null default now(),
11 last_synced_at timestamptz not null default now(),
12 primary key (repo_did, collaborator_did)
13);
14
15create index if not exists tangled_repo_collaborators_user_idx
16 on public.tangled_repo_collaborators (collaborator_did);
17
18create index if not exists tangled_repo_collaborators_repo_idx
19 on public.tangled_repo_collaborators (repo_did);
20
21-- Tracks repos we already checked (including zero collaborators).
22create table if not exists public.tangled_repo_collaborators_sync (
23 repo_did text primary key,
24 collaborator_count integer not null default 0,
25 synced_at timestamptz not null default now()
26);
27
28create or replace view public.tangled_user_collaborations as
29select
30 c.collaborator_did as user_did,
31 c.repo_did,
32 r.owner_handle,
33 r.name as repo_name,
34 r.uri as repo_uri,
35 c.added_by,
36 c.created_at
37from public.tangled_repo_collaborators c
38left join public.tangled_repos r on r.repo_did = c.repo_did;