Branchwell

Skillfarm / website · skillfarm.ai / migrations / 0012_repo_shares_and_comments.sql

1-- Members share a whole GitHub repo. Skillfarm reads it, finds every skill folder, and puts each one in the review queue.
2-- A moderator can deny the whole repo in one step, or approve and deny its skills one by one.
3
4CREATE TABLE repo_imports (
5 id TEXT PRIMARY KEY,
6 user_id TEXT NOT NULL REFERENCES users(id),
7 repo TEXT NOT NULL, -- owner/name as GitHub spells it
8 ref TEXT NOT NULL, -- the commit that was read
9 repo_owner_id TEXT NOT NULL DEFAULT '', -- GitHub's id for the repo owner, to mark a verified owner
10 platforms TEXT NOT NULL,
11 source TEXT NOT NULL DEFAULT 'web', -- web | mcp
12 status TEXT NOT NULL DEFAULT 'reading', -- reading | review | decided
13 found INTEGER NOT NULL DEFAULT 0,
14 decision_note TEXT, -- set when a moderator denies the whole repo
15 decided_by TEXT,
16 decided_at INTEGER,
17 created_at INTEGER NOT NULL,
18 finished_at INTEGER -- when the last skill was read
19);
20CREATE INDEX repo_imports_user ON repo_imports (user_id, created_at);
21CREATE INDEX repo_imports_status ON repo_imports (status, created_at);
22
23CREATE TABLE repo_import_items (
24 id TEXT PRIMARY KEY,
25 import_id TEXT NOT NULL REFERENCES repo_imports(id),
26 path TEXT NOT NULL, -- the skill folder inside the repo; empty for the repo root
27 files TEXT NOT NULL, -- JSON list of { path, rel, size } read from the repo tree
28 status TEXT NOT NULL DEFAULT 'queued', -- queued | working | submitted | updated | unchanged | skipped | failed
29 detail TEXT,
30 skill_id TEXT,
31 version_id TEXT,
32 started_at INTEGER,
33 created_at INTEGER NOT NULL
34);
35CREATE INDEX repo_import_items_import ON repo_import_items (import_id);
36CREATE INDEX repo_import_items_status ON repo_import_items (status, created_at);
37CREATE INDEX repo_import_items_version ON repo_import_items (version_id);
38
39-- Comments on a skill. Any signed-in member can leave one; the author or a moderator can remove it.
40CREATE TABLE comments (
41 id TEXT PRIMARY KEY,
42 skill_id TEXT NOT NULL REFERENCES skills(id),
43 user_id TEXT NOT NULL REFERENCES users(id),
44 body TEXT NOT NULL,
45 created_at INTEGER NOT NULL,
46 removed_at INTEGER,
47 removed_by TEXT
48);
49CREATE INDEX comments_skill ON comments (skill_id, removed_at, created_at);
50CREATE INDEX comments_user ON comments (user_id, created_at);
51
52ALTER TABLE skills ADD COLUMN comments_count INTEGER NOT NULL DEFAULT 0;