pr_01m47d24b0e6n91zwymwxg0vpx/services/integrations/migrations/0001_init.sql

82 lines2,823 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Integrations: your own model provider, alerts that open issues, tickets agents read1-- A workspace's connections to systems outside g1t, and what has crossed
2-- between them. Every timestamp is RFC 3339 UTC.
3
4CREATE TABLE connections (
5 id TEXT PRIMARY KEY,
6 -- The workspace's slug.
7 workspace TEXT NOT NULL,
8 -- anthropic, anthropic_endpoint, sentry, datadog, webhook, jira or linear.
9 provider TEXT NOT NULL,
10 name TEXT NOT NULL,
11 -- Everything but its secrets, as JSON.
12 config TEXT NOT NULL,
13 -- Its key and signing secret, as JSON sealed with AES-256-GCM under the
14 -- service's key and bound to the connection's id. Never returned.
15 secrets TEXT,
16 -- The last four characters of the key, to tell keys apart.
17 secret_hint TEXT,
18 created_by TEXT NOT NULL,
19 created_at TEXT NOT NULL,
20 last_used_at TEXT,
21 last_error TEXT
22);
23CREATE INDEX connections_by_workspace ON connections (workspace, id);
24
25-- An issue's tie to something outside g1t: the Sentry issue that opened
26-- it, the ticket it was imported from. One per outside thing per
27-- connection, so an alert that fires 500 times is one issue.
28CREATE TABLE links (
29 id TEXT PRIMARY KEY,
30 workspace TEXT NOT NULL,
31 connection_id TEXT NOT NULL,
32 provider TEXT NOT NULL,
33 -- The outside system's own id for it, as its API takes it.
34 external_id TEXT NOT NULL,
35 -- What people call it: TECH-1234, or a Sentry short id.
36 key TEXT NOT NULL,
37 title TEXT NOT NULL,
38 url TEXT NOT NULL,
39 repo_id TEXT NOT NULL,
40 -- owner/name.
41 repo TEXT NOT NULL,
42 number INTEGER NOT NULL,
43 -- How many times an alert has fired for it, and the count last
44 -- mentioned on the issue.
45 count INTEGER NOT NULL DEFAULT 1,
46 announced INTEGER NOT NULL DEFAULT 1,
47 -- Whether the outside system has been told work started on it.
48 told_started INTEGER NOT NULL DEFAULT 0,
49 first_seen TEXT NOT NULL,
50 last_seen TEXT NOT NULL,
51 UNIQUE (connection_id, external_id)
52);
53CREATE INDEX links_by_issue ON links (repo_id, number);
54
55-- Requests outside systems sent, kept so people can see what arrived and
56-- what g1t did with it.
57CREATE TABLE deliveries (
58 id TEXT PRIMARY KEY,
59 connection_id TEXT NOT NULL,
60 received_at TEXT NOT NULL,
61 event TEXT NOT NULL,
62 -- opened, updated, reopened, ignored or refused.
63 outcome TEXT NOT NULL,
64 detail TEXT NOT NULL,
65 -- owner/name#number, when it opened or updated an issue.
66 issue TEXT
67);
68CREATE INDEX deliveries_by_connection ON deliveries (connection_id, id);
69
70-- One run's model traffic: what the token a sandbox holds stands for.
71CREATE TABLE model_sessions (
72 -- SHA-256 of the token.
73 token_hash TEXT PRIMARY KEY,
74 workspace TEXT NOT NULL,
75 -- The workspace's own model connection, or null for g1t's.
76 connection_id TEXT,
77 repo TEXT NOT NULL,
78 number INTEGER NOT NULL,
79 task TEXT NOT NULL,
80 expires_at TEXT NOT NULL
81);
82CREATE INDEX model_sessions_by_expiry ON model_sessions (expires_at);