Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

25 linesCodeBlameRaw
1-- Attachments on work items (attachments.rs): a work item filed without a
2-- repository takes files too, kept by the work item (`item_id`, with its
3-- `workspace`, so a deleted workspace's go with it) instead of a
4-- repository. Each row names one or the other.
5CREATE TABLE attachments_new (
6 id TEXT PRIMARY KEY,
7 repo_id TEXT,
8 item_id TEXT,
9 workspace TEXT,
10 user_id TEXT NOT NULL,
11 name TEXT NOT NULL,
12 content_type TEXT NOT NULL,
13 size INTEGER NOT NULL,
14 created_at TEXT NOT NULL,
15 CHECK (repo_id IS NOT NULL OR item_id IS NOT NULL)
16);
17
18INSERT INTO attachments_new (id, repo_id, user_id, name, content_type, size, created_at)
19SELECT id, repo_id, user_id, name, content_type, size, created_at FROM attachments;
20
21DROP TABLE attachments;
22ALTER TABLE attachments_new RENAME TO attachments;
23
24CREATE INDEX attachments_by_repo ON attachments (repo_id);
25CREATE INDEX attachments_by_workspace ON attachments (workspace) WHERE workspace IS NOT NULL;